Skip to content

Instantly share code, notes, and snippets.

@jordinebot
Last active March 11, 2016 12:14
Show Gist options
  • Save jordinebot/df15a8623fb91b3f074b to your computer and use it in GitHub Desktop.
Save jordinebot/df15a8623fb91b3f074b to your computer and use it in GitHub Desktop.
Regular Expressions object for form validation
patterns =
name:
/// ^
[a-z|A-Z|àáèéíòóúÀÁÈÉÍÒÓÚïÏüÜçÇñÑ\-ºª\s]{2,}
$ ///i
email:
/// ^
([\w-\.]+@([\w-]+\.)+[\w-]{2,4})
$ ///i
date:
/// ^
(?:(?:31(\/|-|\.)(?:0?[13578]|1[02]))\1|(?:(?:29|30)(\/|-|\.)(?:0?[1,3-9]|1[0-2])\2))(?:(?:1[6-9]|[2-9]\d)?\d{2})$|^(?:29(\/|-|\.)0?2\3(?:(?:(?:1[6-9]|[2-9]\d)?(?:0[48]|[2468][048]|[13579][26])|(?:(?:16|[2468][048]|[3579][26])00))))$|^(?:0?[1-9]|1\d|2[0-8])(\/|-|\.)(?:(?:0?[1-9])|(?:1[0-2]))\4(?:(?:1[6-9]|[2-9]\d)?\d{2})
$ ///i
phone:
/// ^
\+?\d{9,12}
$ ///i
address:
/// ^
[a-z|A-Z|0-9|àáèéíòóúÀÁÈÉÍÒÓÚïÏüÜçÇñÑ\-ºª,\.\/\s]{2,}
$ ///
postcode:
/// ^
\d{3,8}
$ ///
country:
/// ^
\w{2}
$ ///
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment