Last active
September 9, 2022 03:54
-
-
Save BruceMcKinnon/544b2f57f6c161f25593ac67979299fe to your computer and use it in GitHub Desktop.
Gravity Forms Australian phone number validation mask
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
add_filter( 'gform_phone_formats', 'au_phone_format' ); | |
function au_phone_format( $phone_formats ) { | |
$phone_formats['au'] = array( | |
'label' => 'Australia', | |
'mask' => '99 9999 9999', | |
'regex' => '/^\({0,1}((0|\+61)(2|4|3|7|8)){0,1}\){0,1}(\ |-){0,1}[0-9]{2}(\ |-){0,1}[0-9]{2}(\ |-){0,1}[0-9]{1}(\ |-){0,1}[0-9]{3}$/', | |
'instruction' => 'Australian phone numbers.', | |
); | |
return $phone_formats; | |
} |
Nice one! Cheers M8 🍺
Thanks!
Great! Thanks Bruce!
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Thanks!