Skip to content

Instantly share code, notes, and snippets.

@pauloabmiranda
Last active September 24, 2015 13:48
Show Gist options
  • Save pauloabmiranda/8845518 to your computer and use it in GitHub Desktop.
Save pauloabmiranda/8845518 to your computer and use it in GitHub Desktop.
portuguese regexp forms validation
// validate email, portuguese mobile, dates, and portuguese postal code
email.match( /([0-9a-zA-Z]+[\-._+&])*[0-9a-zA-Z]+@([\-0-9a-zA-Z]+[.])+[a-zA-Z]{2,6}/ );
portuguese_mobile.match( /^([3]\d{8})|([2]\d{8})|([9][1|2|3|4|6]\d{7})$/ );
date.match( /(\d{4}|(0[1-9]|[12][0-9]|3[01]))[\s\-\/](0[1-9]|1[012])[\s\-\/]((\d{4})|(0[1-9]|[12][0-9]|3[01]))/ );
portuguese_postal_code.match( /^\d{4}(-\d{3})?$/ );
day.match(/^(0[1-9]|[12][0-9]|3[01]|[1-9])$/);
month.match(/^(0[1-9]|1[012]|[1-9])$/);
year.match(/^([12][09][0-9][0-9])$/);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment