Skip to content

Instantly share code, notes, and snippets.

@sundayu
Last active December 16, 2015 07:49
Show Gist options
  • Save sundayu/5401936 to your computer and use it in GitHub Desktop.
Save sundayu/5401936 to your computer and use it in GitHub Desktop.
JavaScript: validator
App.validator =
check: (str, regexp)->
@[regexp].test str
url: /^(https?:)\/\/([a-z0-9]([-a-z0-9]*[a-z0-9])?\.)+([a-zA-z]{2,6})(\/[a-zA-Z0-9$_.+!#*(),;\/?:@&~=%-]*)?$/
email: /^([\w\.\-\+\=]+)@((?:[a-z0-9\-_]+\.)+[a-z]{2,6})$/i
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment