Skip to content

Instantly share code, notes, and snippets.

@ismnoiet
Created March 7, 2016 09:42
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ismnoiet/f0adf8267635091cd688 to your computer and use it in GitHub Desktop.
Save ismnoiet/f0adf8267635091cd688 to your computer and use it in GitHub Desktop.
window.validator = {
tel:/^0[0-9]{8,9}$/,
fax:/^0[0-9]{8}$/,
mob:/^0[0-9]{9}$/,
username:/^[a-z0-9_-]{3,16}$/,
name:/^[a-z ]+$/,
email:/^([a-z0-9_\.-]+)@([\da-z\.-]+)\.([a-z\.]{2,6})$/,
url:/^(https?:\/\/)?([\da-z\.-]+)\.([a-z\.]{2,6})([\/\w\.\-&\?=]*)*\/?$/,
anything:/.+?$/,
test:function(type,str){
return this[type].test(str);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment