Trending News
Home / Web Development / HTML / Retype password Validation – Javascript

Retype password Validation – Javascript

Hi Guys,
Here I explain, how to check Password and Confirm Password validation for Password TextBox using pur javascript method with demo.
The Password and Confirm password are in textboxes. And these are compared using JavaScript and if the values do not match an error message will occur like password must be same. If the values match then display the sucess message like ‘you are valid user Thanks for visiting our site. We can performe these operations by pure php code or javascript with jquery also.

In password validation, the table of contents are:

  • The HTML
  • The JavaScript


The two input text boxes are specified within the form tag. Also the function all specifie in HTML. The function call in form tag on page submit, using onsubmit nethod.

The JavaScript

Here, check the password and confirm password are correct using function. If password and confirm password are not matched then the error message will display.


Full Code

The Action perform on form submit. Call the testpass() function at onsumit event handler. When the Button is clicked, the Validate JavaScript function gets executed.

Inside the Validate JavaScript function(testpass()), the values of the Password and the Confirm Password TextBoxes are fetched and are compared. If the values do not match an error message will occur using JavaScript alert message box and false value is returned in order to stop the form submission otherwise the success message is displayed using javascript alert message box.

If anyone has doubts on this topic then please do let me know by leaving comments or send me an email.

Loading Facebook Comments ...
Social Media Auto Publish Powered By :