Registration form validation in javascript using regular expression with example

main

Regular expressions are generally used for form validations.You can validate text field value using patterns in regular expressions.Regular expressions are used in every programming languages.

You can easily validate pattern in every languages,languages such as java, php, dot net provides separate functions to match pattern with text from text field.

I have implemented a simple html form and validate it using a regular expression pattern.Here i am providing a simple code which gives you an idea that how yo can implement form validation using regular expression.Regular expressions are fastest way to check input from registration form.

Here we are providing regular expression for following inputs:

1) Name: name field validation in javascript using regular expression is very easy to implement and it provide quickest result than coding and using different logic to check input from text field.It restrict the user to provide correct input for name field.

2) Email:email id field commonly used in almost every registration form to take it as an input.This input field is mandatory in many forms as email id contains uniqueness for each user.Email id contains its own pattern for each email id .while entering input to text field user must follow that pattern if its not followed by user then it must be a fake id enter by user.

3) Mobile Number : Mobile number contains different formats for different countries while here we implement regular expression for Indian mobile number.While entering mobile number you can also check country code and then the respective format of your country’s mobile number

4) Pin code: Pin code generally contain 6 digits only. So while taking input form user restrict them to enter pincode for 6 digit long and also it must contain only digits.

Must Read

How to store Microsoft Excel,Comma Separated Values(.csv) files in database using php

Click below link to download the source code

download

 

Leave a comment

Your email address will not be published. Required fields are marked *