Wednesday, February 25, 2009

Regular Expresions JavaScript

My list of Regular Expressions used in validating forms using JavaScript
  • Checking Email Addresses,
    remail = /^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/;   
  • Checking a persons name,
    rename = /^((?:[A-Z](?:('|(?:[a-z]{1,3}))[A-Z])?[a-z]+)|(?:[A-Z]\.))(?:([ -])((?:[A-Z](?:('|(?:[a-z]{1,3}))[A-Z])?[a-z]+)|(?:[A-Z]\.)))?$/;
  • Checking the contents of a message or text box to make sure that only the characters intend are being used,
    remess = /^[0-9A-Za-z\,\.\'\-\s]+$/;

No comments:

Post a Comment