My html code like this :
<form class="validatedForm" id="commentForm" method="get" action="">
<fieldset>
<input name="password" id="password" />
<input name="password_confirmation" />
</fieldset>
</form>
<button>Validate</button>
My javascript code to validate with jquery validate like this :
jQuery('.validatedForm').validate({
rules: {
"password": {
minlength: 6
},
"password_confirmation": {
minlength: 6,
equalTo : "#password"
}
},
messages: {
"password": 'Please enter a password, minimal 6 characters',
"password_confirmation": 'Please confirm your password'
},
});
Demo and full code like this : http://jsfiddle.net/oscar11/fEZFB/609/
If user input password : abcdef
, then click button validate, there exist messsage : "Please confirm your password"
If user input password confirmation : ghijkl
, there exist message : "Please confirm your password"
I want to change the message if user input password confirmation not same
The message like this : "confirm your password is not the same"
So there exist two message :
- If user not input password confirmation, the message : "Please confirm your password"
- If user input password confirmation, but not same with password, the message : "confirm your password is not the same"
How can I do it?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…