I have two inputs, e.g.
pass: <input type="password" name="pass" required/>
pass again: <input type="password" name="pass2" required/>
and I want to compare these inputs, and if they match, set input as valid. I tried this, but I think that prop('valid', true);
does not work:
$(document).ready(function() {
$('input[name=pass2]').keyup(function() {
if($('input[name=pass]').val() == $('input[name=pass2]').val()) {
$('#pass_hint').empty();
$('#pass_hint').html('match');
$(this).prop('valid', true);
} else {
$('#pass_hint').empty();
$('#pass_hint').html('mismatch');
$(this).prop('invalid', true);
}
});
});
I create a registration form and if passwords are not the same, input field is invalid and I can′t submit this and show me some hint. ...and I don′t know how I set this input as invalid
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…