Skip to content

Instantly share code, notes, and snippets.

@alioguzhan
Created March 22, 2013 21:16
Show Gist options
  • Save alioguzhan/5224821 to your computer and use it in GitHub Desktop.
Save alioguzhan/5224821 to your computer and use it in GitHub Desktop.
// Validate Phone Format
var filter = /^\(?(\d{3})\)?[- ]?(\d{3})[- ]?(\d{4})$/;
// Validate Email Format
var filter = /^([\w-\.]+)@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.)|(([\w-]+\.)+))([a-zA-Z]{2,6}|[0-9]{1,3})(\]?)$/;
// Validate Date Format (Short Date mm/dd/yyyy)
var filter = /^(0?[1-9]|1[012])\/(0?[1-9]|[12][0-9]|3[01])\/(?:19|20|21\d{2})/;
// Validate URL Format
var filter = /^(ftp|http|https):\/\/[A-Za-z0-9\.-]{1,}\.[A-Za-z]{2}/
// To Verify if a text has the right format
var result = filter.test(textToValidate);
// NOTE: result will be true if format is correct otherwise false.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment