Skip to content

Instantly share code, notes, and snippets.

@gayanhewa
Created February 16, 2017 09:47
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save gayanhewa/d6544c325f901b559f191f652aaa0dcd to your computer and use it in GitHub Desktop.
Save gayanhewa/d6544c325f901b559f191f652aaa0dcd to your computer and use it in GitHub Desktop.
jquery validator australian phone number
jQuery.validator.addMethod("au_phone", function(value, element) {
return this.optional(element) || /^(?:\+?(61))? ?(?:\((?=.*\)))?(0?[2-57-8])\)? ?(\d\d(?:[- ](?=\d{3})|(?!\d\d[- ]?\d[- ]))\d\d[- ]?\d[- ]?\d{3})$/.test(value);
}, "Invalid phone number");
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment