在验证表单时,它工作正常,但
它是先给消息 for Description
then for Code
then for Name
。但我希望验证应该首先为Name
然后Code
为Description
$(document).ready(function() {
$("#added").validate({
rules: {
Name: {
required: true
},
Code: {
required: true
},
Description: {
required: true
},
},
messages: {
Name: {
required: "Enter Name"
},
Code: {
required: "Enter code"
},
Description: {
required: "Enter Description"
},
},
errorPlacement: function(error, element) {
$("#error-messages").html(error); // error container
}
});
});
HTML:
<div id="error-messages"></div>
<s:form action="added" id="added" method="post" >
<s:textfield name="Name" id="Name" label="Name" labelposition="top" />
<s:textarea name="Code" id="Code" rows="10" cols="50"
label="Code" labelposition="top"/>
<s:textarea name="Description" id="Description" rows="5" cols="50"
label="Description" labelposition="top"/>
<s:form>
如何解决这个问题?