jQuery显示表单警报框 [英] jQuery display form alert box
本文介绍了jQuery显示表单警报框的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在尝试显示一个警报或可设置样式的弹出框,当按下提交"按钮时,该框会显示空字段".添加alert("Empty Fields!!");
Hi i'm trying to display an alert or style-able popup box that says Empty Fields when the submit button is press. The code below stopped working after I added alert("Empty Fields!!");
var validator = $("#reg_form").validate({
errorLabelContainer: $("#reg_form div.error"),
meta: "validate",
alert("Empty Fields!!");
});
推荐答案
我假设 http://docs.jquery.com/Plugins/Validation/validate 是您的代码所引用的jQuery插件.
I assume that http://docs.jquery.com/Plugins/Validation/validate is the jQuery plugin that your code referes to.
您不能在类声明中使用警报.您将必须像这样重写它:
You can't use alert in class declaration. You will have to rewrite it like this:
var validator = $("#reg_form").validate({
errorLabelContainer: $("#reg_form div.error"),
meta: "validate",
submitHandler: function( form ) {
alert("Empty Fields!!");
}
});
或使用invalidHandler:function(form,validator)代替SubmitHandler
or use invalidHandler: function(form, validator) instead of submitHandler
这篇关于jQuery显示表单警报框的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文