If you have a form with a ‘confirm password’ field or ‘confirm email’, and you don’t want to use a heavy validation plugin just for a simple confirmation like this, you can always use some simple ‘old school’ javascript and the onblur event, so when the field loses focus triggers the validation function.
<script type="text/javascript"> function confirmPass() { var pass = document.getElementById("pass").value var confPass = document.getElementById("c_pass").value if(pass != confPass) { alert('Wrong confirm password !'); } } </script> <form id="form" action="" method="post"> <label for="pass">Password</label> <input type="password" id="pass" class="text" name="your_pass" value=""/> <label for="c_pass">Confirm Password</label> <input type="password" id="c_pass" class="text" name="your_c_pass" value="" onblur="confirmPass()"/> </form>
See a demo.
Thanks a lot
tesat
I think this is wrong confirmation, because it has a bug. When you have written right password and confirmation and then change first password input it does not has the reaction.
That happens, due to the fact that the ‘validation’ function is called when the ‘onblur’ event is triggered only on the ‘Confirm Password’ field.
This is more like an example, not a real world password confirm validation.
email and confirm email validation in php
when email and confirm email value are same then data send to database otherwise not…
how it is…plzz send code …
Here can find the correct way to do it people (in JS & in JQ)
https://www.aspsnippets.com/Articles/Password-and-Confirm-Password-validation-using-JavaScript-and-jQuery.aspx