I am unable to validate the spring for which have two password fields.
If i change from form:password to input type="password" it starts working , but then data does not gets bind with commandName, and i receive null in controller.
<form:form action="changepas" commandName="mypwd" method="post" id="cngpwdform">
<div>
<table>
<tr><td>Current Password</td>
<td><form:password id="curPass" name="curPass" path="pwd" /></td>
</tr><tr>
<td>New Password <td>
<form:password id="newPassword" name="newPassword" path="nwpass" /></td>
</tr><tr>
<td><input type="submit" value="Change Password" /></td>
</tr>
</form:form>
Now we have this JQuery validation
$(document).ready(function() {
$("#cngpwdform").validate({
rules : {
'curPass' : {
required : true
},
'newPassword' : {
required : true
}
}
});
});
Please tell me one thing.
I have few other forms which perfectly binds data with commandName and are like < form > < / form > and i use < input > tags in them, works fine, but to add password fields i am getting null value in the controller. Then to resolve this i have to use the < form : form > and for field i have to use < form : password > but then jQuery does not validates it.... Can you sens what could be wrong with this ?
Adding Generated HTML as asked by Sparky : My God !! name attribute is appearing twice, once the name i had given and another the path name.
<form id="cngpwdform" action="changepas" method="post">
<div>
<table>
<tr>
<td>Current Password</td><td><input id="curPass" name="pwd" name="curPass" type="password" value=""/>
</td></tr>
<tr>
<td>New Password<td><input id="newPass" name="nwpass" name="newPass" type="password" value=""/>
</td></tr>
<tr>
<td><input type="submit" value="Change Password"/>
</td></tr>
</form>
Can you try this:
<form:password id="curPass" name="curPass" path="curPass" />
If you view source on your rendered HTML and maybe put a break point in firebug for your jquery validate function you will notice that the validate is not being fired.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.