我在使用jquery验证插件(http://jqueryvalidation.org)和jquery ui对话框时遇到了问题.我在这里读到:jQuery UI Dialog验证没有使用<form>标签, 但建议的仍然不起作用.
下面是我的jQuery:
$( '#addModal' ).dialog({
autoOpen: false,
modal: true,
buttons: {
'Create': function() {
$( '#addForm' ).validate({
rules: {
titleAdd: { required: true },
descriptionAdd: { required: true }
},
submitHandler: function( form ) {
$( this ).dialog( 'close' );
// ... AJAX call
} //end submitHandler
}); //end validate()
},
Cancel: function() {
$( this ).dialog( 'close' );
}
} //end buttons
}); //end Create Form Modal
Run Code Online (Sandbox Code Playgroud)
下面是HTML:
<div id="addModal" title="Add new …Run Code Online (Sandbox Code Playgroud)