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

问题描述:

我需要验证3个文本字段,并在这些字段上显示红色边框高亮显示,但是在输入所有3个字段后要显示一条常见的错误消息.

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个文本字段:

<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" />

字段验证:

是必填字段

只允许输入数字,而只能输入2个数字.

Only numbers are allowed and exact 2 numbers should be allowed.

客户端验证:

我需要对模糊应用验证,单击提交按钮将验证服务器端.

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.

建议使用jquery验证程序插件.阅读文档,您可以修改方法以执行自己喜欢的事情.这些论坛上有很多示例可以帮助您了解如何使用它.以及在线.

suggest using the jquery validator plugin. 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