Require Australian Mobile Number

Code

Filename: gpapf-require-australian-mobile-number.php

<?php
/**
 * Gravity Perks // Advanced Phone Field // Require Australian Mobile Number
 * https://gravitywiz.com/documentation/gravity-forms-advanced-phone-field/
 */
// Update "123" to your form ID and "4" to your Phone field ID.
add_filter( 'gform_field_validation_123_4', function( $result, $value ) {
	if ( $result['is_valid'] && substr( $value, 0, 4 ) !== '+614' ) {
		$result['is_valid'] = false;
		$result['message']  = 'Please enter a mobile number.';
	}
	return $result;
}, 10, 2 );

Leave a Reply

Your email address will not be published. Required fields are marked *

  • Trouble installing this snippet? See our troubleshooting tips.
  • Need to include code? Create a gist and link to it in your comment.
  • Reporting a bug? Provide a URL where this issue can be recreated.

By commenting, I understand that I may receive emails related to Gravity Wiz and can unsubscribe at any time.