阻止jQuery验证消息,直到提交

编程入门 行业动态 更新时间:2024-10-28 15:28:32
本文介绍了阻止jQuery验证消息,直到提交的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我只想在键入字段期间和之后隐藏所有错误消息(错误的输入或空白的字段).按下提交/按钮后,消息将全部显示/可见.

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验证消息,直到提交

本文发布于:2023-10-24 15:09:47,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1524270.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:消息   jQuery

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!