简体   繁体   English

多个字段验证…一条错误消息

[英]multiple field validations…with one error message

I need to validate 3 textfields and show red border highlights on the fields but a common error message to show after all 3 fields have been entered. 我需要验证3个文本字段,并在字段上显示红色边框高亮显示,但是在输入所有3个字段后要显示一条常见的错误消息。

I have 3 text fields: 我有3个文本字段:

<label>LABEL TEXT</label>
<input type="text" value="" size="2" maxlength="2" class="formInput" name="code1" />
<input type="text" value="" size="2" maxlength="2" class="formInput" name="code2" />
<input type="text" value="" size="2" maxlength="2" class="formInput" name="code3" />

Field validations: 现场验证:

Are mandatory fields 是必填字段

Only numbers are allowed and exact 2 numbers should be allowed. 仅允许输入数字,并且应允许输入精确的2个数字。

Client-side validations: 客户端验证:

I need to apply validations on blur and on the click of a submit button it will validate server side. 我需要对模糊应用验证,然后单击提交按钮将验证服务器端。

I need to apply validations in the following manner---- On blur of the first and second, I need to highlight the fields for invalid entries. 我需要以以下方式应用验证:在第一和第二模糊时,我需要突出显示无效条目的字段。 But show a common error message (label will be replaced with an error message) after blurring/entering the data in all the three fields. 但是在模糊/输入所有三个字段中的数据后,显示一个常见的错误消息(标签将被错误消息替换)。

Please ask questions if anything above is NOT clear...any help much appreciated. 如果以上内容不清楚,请询问问题...非常感谢您的帮助。

suggest using the jquery validator plugin. 建议使用jquery验证程序插件。 read the documentation, you can modify the methods to do what you like. 阅读文档,您可以修改方法以执行所需的操作。 there are plenty of examples on these forums to help you see how to use it. 这些论坛上有很多示例可以帮助您了解如何使用它。 as well as online. 以及在线。

http://rocketsquared.com/wiki/Plugins/Validation#Validator http://rocketsquared.com/wiki/Plugins/Validation#Validator

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM