我想更改使用 Verify.js 提交表单时 data-validate 返回 false 时提示的文本
表格:
<form>
<input name="test" value="" data-validate="required">
<input type="submit" class="submit">
</form>
我尝试在外部 js 文件中使用它,但它不起作用:
$(document).ready(function(){
$.verify.updateRules({required:{message:"another text"}});
});
最佳答案
只是将其作为“答案”...研究完此问题后,我决定将其作为问题输入到Verify.js 存储库中:https://github.com/jpillora/verifyjs/issues/32
虽然Verify.js提高了其API的稳定性,但我建议您使用http://jqueryvalidation.org/ 。它非常成熟并且易于使用。对于您的用例,您可能对 rules
fn 感兴趣:
$( ".test" ).rules( "add", {
required: true,
minlength: 2,
messages: {
required: "Required input",
minlength: jQuery.validator.format("must be at least {0} characters")
}
});
关于javascript - 如何更改Verify.js的消息?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32292284/