Skip to content

Instantly share code, notes, and snippets.

@canokay
Last active August 14, 2018 19:24
Show Gist options
  • Save canokay/bc3081aa812643bc7946ba663ff4a079 to your computer and use it in GitHub Desktop.
Save canokay/bc3081aa812643bc7946ba663ff4a079 to your computer and use it in GitHub Desktop.
Password Confirm Snippet
<!doctype html>
<html lang="en">
<head>
<title>Password Confirm Snippet</title>
<!-- Required meta tags -->
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<!-- Bootstrap CSS -->
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.1.2/css/bootstrap.min.css" integrity="sha384-Smlep5jCw/wG7hdkwQ/Z5nLIefveQRIY9nfy6xoR1uRYBtpZgI6339F5dgvm/e9B" crossorigin="anonymous">
</head>
<body>
<form>
<div class="form-group col-4 ml-auto mr-auto">
<div class="form-group">
<input type="password" class="form-control" id="password" name="password" placeholder="Create a password">
</div>
<div class="form-group">
<input type="password" class="form-control" id="rpassword" name="rpassword" placeholder="Confirm password" onkeyup="checkPass(); return false;">
<span id="confirmMessage" class="confirmMessage"></span>
</div>
<div class="form-group">
<button id="m_login_reset_password" class="btn btn-success">
Save
</button>
</div>
</div>
</form>
<!-- Password Confirm JavaScript -->
<script src="password_confirm.js"></script>
<!-- jQuery first, then Popper.js, then Bootstrap JS -->
<script src="https://code.jquery.com/jquery-3.3.1.slim.min.js" integrity="sha384-q8i/X+965DzO0rT7abK41JStQIAqVgRVzpbzo5smXKp4YfRvH+8abtTE1Pi6jizo" crossorigin="anonymous">
</script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.3/umd/popper.min.js" integrity="sha384-ZMP7rVo3mIykV+2+9J3UJ46jBk0WLaUAdn689aCwoqbBJiSnjAK/l8WvCWPIPm49" crossorigin="anonymous">
</script>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.1.2/js/bootstrap.min.js" integrity="sha384-o+RDsa0aLu++PJvFqy8fFScvbHFLtbvScb8AjopnFD+iEQ7wo/CG0xlczd+2O/em" crossorigin="anonymous">
</script>
</body>
</html>
function checkPass() {    
var password = document.getElementById('password');    
var rpassword = document.getElementById('rpassword');    
var message = document.getElementById('confirmMessage');       
if (password.value == rpassword.value) {
message.innerHTML = ""; 
document.getElementById("m_login_reset_password").disabled = false;  
$("#m_login_reset_password").text("Save");              
} else { 
message.style.color = "#ff6666";        
message.innerHTML = "Password don't match!";       
document.getElementById("m_login_reset_password").disabled = true;  
}
}; 
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment