Confirm password with form validation in JavaScript Code examples

Confirm password with form validation in JavaScript Code examples

Form validation is a process to validate that user is submitting the data according to correct format or not. Most of the time it happens that user enter the password during registration and he thinks that he enter the password as he thinks but unfortunately due to the wrong fingers on the keyboard his password is set to some other password.

For example, the user wants to enter the password as;

Password: asdf

but mistakenly he enters the password as follows; 

Password: asdg

In such conditions, there is a problem for the user. To avoid this problem, we as a web developer asks the user to enter the password two times.  Form validation can be done by JavaScript.

Example of code for Confirm password form validation in JavaScript

Let’s verify password and confirm password fields in HTML using JS.

Example of code for Confirm password form validation in JavaScript with detailed HTML code

Regular expression for password strength validation in Javascript

Let’s dicuss the Regular expression;

var strongRegex = new RegExp(“^(?=.*[a-z])(?=.*[A-Z])(?=.*[0-9])(?=.*[[email protected]#\$%\^&\*])(?=.{8,})”);

RegExDescription
^The password string starting.
(?=.*[a-z])Must contain at least 1 lowercase alphabetical character from a to z.
(?=.*[A-Z])Must contain at least 1 uppercase alphabetical character from A to Z.
(?=.*[0-9])Must contain at least 1 numeric character from 0 to 9.
(?=.*[[email protected]#$%^&*])Must contain at least one special character.
(?=.{8,})Must be eight characters or longer string

Re-enter password validation Javascript

Strong password validation in javascript

 

Topic Covered

Confirm password with form validation in JavaScript Code examples

 
List of All Programs of Javascript : Click Here 
.

Subscribe for Friendship

Latest posts by Prof. Fazal Rehman Shamil (see all)

Buy advertisement space on T4Tutorials

For more details email [email protected]