у меня есть этот HTMLJavascript отключить/включить кнопку отправки, когда пароль матч
> <div class="row">
> <div class="col-xs-6 col-sm-6 col-md-6">
> <div class="form-group">
> <input type="password" name="pass1" id="pass1" class="form-control input-lg" placeholder="Password"
> tabindex="3">
> </div>
> </div>
> <div class="col-xs-6 col-sm-6 col-md-6">
> <div class="form-group">
> <input type="password" name="pass2" id="pass2" onkeyup="checkPass(); return false;" class="form-control
> input-lg" placeholder="Confirm Password ">
> <span id="confirmMessage" class="confirmMessage"></span>
> </div>
>
> </div>
>
> </div>
>
> <div class="row">
> <input type="submit" id="login" value="Register">
> </div>
Как я могу сделать что-то вроде этого:
Если пароль пустой Представлять должен быть отключен (отключен = "отключен «).
Когда что-то вводится в passsword, чтобы удалить отключенный атрибут.
Если поле пароля снова пуст (текст удален), кнопка отправки должна быть снова отключена.
Если пароль не совпадает, то кнопка представить, должны быть отключить
Я пытался что-то вроде этого:
<script type="text/javascript">
function checkPass()
{
//Store the password field objects into variables ...
var pass1 = document.getElementById('pass1');
var pass2 = document.getElementById('pass2');
//Store the Confimation Message Object ...
var message = document.getElementById('confirmMessage');
//Set the colors we will be using ...
var goodColor = "#66cc66";
var badColor = "#ff6666";
//Compare the values in the password field
//and the confirmation field
if(pass1.value == pass2.value){
//The passwords match.
//Set the color to the good color and inform
//the user that they have entered the correct password
pass2.style.backgroundColor = goodColor;
message.style.color = goodColor;
message.innerHTML = "Passwords Match!"
}else{
//The passwords do not match.
//Set the color to the bad color and
//notify the user.
pass2.style.backgroundColor = badColor;
message.style.color = badColor;
message.innerHTML = "Passwords Do Not Match!"
$("#submit").attr("disabled", "disabled");
}
}
</script>
сообщение яваскрипта дисплея, если пароль соответствуют или не соответствует, но моя проблема в том, когда пароль не соответствует кнопке SUBMIT, все еще идет вперед и отправляется.
все еще не работает – youngdero
все еще не работает – youngdero
прикреплять 'checkPass' на' onkeyup' поля 'pass1' тоже. – meskobalazs