JSFiddle - React, Tailwind, and code Playground
by Lalji Tadhani
HTML
<form name="resetform" action="login/change.php" id="resetform" class="passform" method="post" role="form">
<h3>Change Your Password</h3>
<br />
<input type="hidden" name="username" value="<?php echo $sname; ?>" >
<label>Enter Old Password</label>
<input type="password" class="form-control field" name="currentPassword" id="old_password">
<label>Enter New Password</label>
<input type="password" class="form-control field" name="newPassword" id="new_password">
<label>Confirm New Password</label>
<input type="password" class="form-control field" name="con_newpassword" id="con_newpassword" />
<br>
<input type="submit" class="btn btn-primary" name="updatepass" id="submit_btn" disabled value="Change Password" />
</form>
JavaScript
$('.passform input').keyup(function() {
var empty = false;
$('.passform input').each(function() {
if ($(this).val().length == 0) {
empty = true;
}
});
console.log(empty);
if (empty || !($('#new_password').val() === $('#con_newpassword').val())) {
$('#submit_btn').attr('disabled', 'disabled');
} else {
$('#submit_btn').attr('disabled', false);
}
});