A Pen by Diego Leme on CodePen.
Created
December 26, 2018 00:16
-
-
Save AhmadMunir/f77d1a3be691adf4f0e755d8021f784e to your computer and use it in GitHub Desktop.
Confirm password with HTML5
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<form class="pure-form"> | |
<fieldset> | |
<legend>Confirm password with HTML5</legend> | |
<input type="password" placeholder="Password" id="password" required> | |
<input type="password" placeholder="Confirm Password" id="confirm_password" required> | |
<button type="submit" class="pure-button pure-button-primary">Confirm</button> | |
</fieldset> | |
</form> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var password = document.getElementById("password") | |
, confirm_password = document.getElementById("confirm_password"); | |
function validatePassword(){ | |
if(password.value != confirm_password.value) { | |
confirm_password.setCustomValidity("Passwords Don't Match"); | |
} else { | |
confirm_password.setCustomValidity(''); | |
} | |
} | |
password.onchange = validatePassword; | |
confirm_password.onkeyup = validatePassword; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<script src="//cdnjs.cloudflare.com/ajax/libs/jquery/2.1.3/jquery.min.js"></script> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<link href="https://yui.yahooapis.com/pure/0.5.0/pure-min.css" rel="stylesheet" /> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment