1

我正在使用 jquery.validate 插件。我在 jquery ui 对话框中有一个 html 表单。当用户打开对话框并尝试提交表单时,如果表单包含验证错误,同时如果用户关闭对话框并且当他再次打开它时,验证消息仍然存在。我还创建了一个小提琴:

http://jsbin.com/aralur/4/edit

如何解决这个问题?

4

3 回答 3

1

只需使用这种方式:

$('.ui-icon-closethick').click(function(){
    $('.error').text('');
});

并在此处的工作箱中看到-

http://jsbin.com/aralur/5/edit

.

于 2012-12-06T08:21:59.680 回答
0

感谢您的回答,我也找到了我想与您分享的问题的解决方案。我们可以在jquery ui 对话框中使用resetForm()jquery.validate 插件的功能。beforeClose event这是一个工作小提琴:

http://jsbin.com/aralur/11/edit

于 2012-12-06T08:31:20.790 回答
0

只需在打开对话框之前隐藏错误消息,如下所示:) 这是一种简单的方法。

$("#order").bind("click", function(){ 
  $("label.error").hide();
  $("#orderform").dialog("open");
});
于 2012-12-06T08:25:16.667 回答