在让用户继续之前,如何确保密码字段匹配?
<input name="pass" id="pass" type="password" />
<input type="password" name="cpass" id="cpass" /> <span id='message'></span>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<script>
$('#pass, #cpass').on('keyup', function () {
if ($('#pass').val() == $('#cpass').val()) {
$('#message').html('Matching').css('color', 'green');
}
else $('#message').html('Not Matching').css('color', 'red');
});
</script>
<input type="text" name="phone" id="phone">
最佳答案
使用 jquery 可以删除电话输入的禁用属性:
<input type="text" name="phone" id="phone" disabled />
$('#pass, #cpass').on('keyup', function () {
if ($('#pass').val() == $('#cpass').val()) {
$('#message').html('Matching').css('color', 'green');
$("#phone").prop('disabled', false);
}
else $('#message').html('Not Matching').css('color', 'red');
});
关于javascript - 检查密码是否匹配,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27498084/