Form validation

Name

pattern=”^[a-zA-Z]+(?:[_ -a-zA-Z0-9 !@#$%^&*|<>.,])*[a-zA-Z 0-9 !@#$%^&*|<>.,]*$”

This pattern will satisfy the following conditions.

  • The name accepts symbols (ex: Victoria 2)
  • The name accepts combinations of alphabets and special characters (ex: Test Victoria ||| & Company).
  • The name field does not accept all numerals.
  • The name field does not accept all white spaces.
  • The name field does not accept all special characters.

Email

pattern=”[A-Za-z0-9._%+-]+@[A-Za-z0-9-]+\.[A-Za-z]{1,63}$”

This pattern will satisfy the following conditions

  • Email id filed with the ‘+’ sign after @ is not considered valid.
  • Square brackets around the Email address is not valid.
  • Email id field with quotes around email is not valid.
  • Email id field with digits at the domain name is not accepted.
  • Email id field with “_”/”-” is not accepted.

Phone Number

pattern=”^+(9[976]\d|8[987530]\d|6[987]\d|5[90]\d|42\d|3[875]\d|

          2[98654321]\d|9[8543210]|8[6421]|6[6543210]|5[87654321]|

          4[987654310]|3[9643210]|2[70]|7|1)\d{1,14}$”

This pattern will satisfy the following conditions

  • Phone Number field with less than 10 digits accepted.
  • Does not accept all Zero in the mobile number field.
  • Mobile No field with 10 blank spaces will not be accepted.
  • Entering character value is not accepted.
  • International mobile number formats such as +61 7441 5432 are accepted

Leave a comment

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