Require users to confirm their password

Article author
Josh Lopez
  • Updated

Here is a demo site with the code below installed so you can see it in action: confirm-password.webflow.io

 

Step 1:

Page header script:
Paste the script below in the <head></head> tag on your website. If you are using webflow, jQuery is already included and this script is not needed.

 

<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/2.1.3/jquery.min.js"></script>

 

Page footer script:
Paste the script below just above the </body> tag on your website.

 

<script>
var password = document.getElementById("password");
var 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();
</script>


NOTE: Remove the ms-field="password" from the second input field. Only one password field should be submitted to Memberstack.

 

Other resources

Finsweet → Password confirm validation with Webflow Interactions

Was this article helpful?

Comments

0 comments

Please sign in to leave a comment.