Skip to content

Instantly share code, notes, and snippets.

@BruceMcKinnon
Last active September 9, 2022 03:54
Show Gist options
  • Save BruceMcKinnon/544b2f57f6c161f25593ac67979299fe to your computer and use it in GitHub Desktop.
Save BruceMcKinnon/544b2f57f6c161f25593ac67979299fe to your computer and use it in GitHub Desktop.
Gravity Forms Australian phone number validation mask
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;
}
@codewithAmitg
Copy link

Thanks!

@PodClay
Copy link

PodClay commented Sep 9, 2022

Great! Thanks Bruce!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment