我只想在键入字段期间和之后隐藏所有错误消息(错误的输入或空白的字段).按下提交/按钮后,消息将全部显示/可见.
I just want to hide all the error message during and after typing the field (wrong input or empty field). And once the submit/button pressed then the message will all appear/visible.
问题是...每次我输入错误或将文本字段留空时,它总是显示错误消息,例如此字段是必需的",等等.
The problem is... every time I typed wrong or I leave the text field empty it always shows the error message such "this fields is required", etc.
rules : { "user.firstname" : { required : true, maxlength: 50, }, messsages : { required : "required", maxlength: "the max-length is 50" " }推荐答案
根据在线文档,则需要使用onfocusout:和onkeyup:选项.
As per online documentation, you need to use the onfocusout: and onkeyup: options.
在模糊时验证元素(复选框/单选按钮除外).如果 不输入任何内容,所有规则都将被跳过,除非该字段为 已经被标记为无效.
Validate elements (except checkboxes/radio buttons) on blur. If nothing is entered, all rules are skipped, except when the field was already marked as invalid.
此禁用 onblur验证:
This disables onblur validation:
onfocusout: false
验证键盘上的元素.只要该字段未标记为 无效,没有任何反应.否则,将检查每个键上的所有规则 向上事件.
Validate elements on keyup. As long as the field is not marked as invalid, nothing happens. Otherwise, all rules are checked on each key up event.
此禁用 onkeyup验证:
This disables onkeyup validation:
onkeyup: false
根据您是否具有复选框和单选按钮,您可能还希望禁用onclick:选项.
And depending on if you have checkboxes and radio buttons, you may want to disable the onclick: option as well.
在点击时验证复选框和单选按钮.
Validate checkboxes and radio buttons on click.
此禁用 onclick验证:
This disables onclick validation:
onclick: false更多推荐
阻止jQuery验证消息,直到提交
发布评论