Catalog Item field validation for mobile phone number

Arijit Saikia
Tera Contributor

Hi,

I am creating a Catalog Item. One of the field is Mobile Number.

 

Can you please guide me how can I set up validation for the field. The requirement is that:

It should start with +61

The total number of digits (including the 61) should be 11.

 

Thanks

 

 

1 ACCEPTED SOLUTION

Sai Kumar B
Mega Sage
Mega Sage

@Arijit Saikia 

You can choose any of the following options

1.) You can write onChange() client script on phone number variable to validate

Sample script 

 

if (newValue) {
var number = newValue.toString(); //Convert phone number to string
if ( number.substring(0,2) != '61' || number.length < 11) { //If number doesn't start with 61 or length is less than 11
g_form.showFieldMessage('pass_variable_name_here', 'pass message here', 'error');
g_form.clearValue('pass_variable_name_here');
}
}

 


2.) You can create a validation regex for a phone number in "Variable validation regex" under the catalog variables module in the Application Navigator and You can apply that regex in the variable record "Type specifications" tab

 

If I could help you with my response you can mark it as helpful and correct as it benefits future viewers
Thanks,
Sai Kumar B
Community Rising Star 2023 & 2022

 

View solution in original post

1 REPLY 1

Sai Kumar B
Mega Sage
Mega Sage

@Arijit Saikia 

You can choose any of the following options

1.) You can write onChange() client script on phone number variable to validate

Sample script 

 

if (newValue) {
var number = newValue.toString(); //Convert phone number to string
if ( number.substring(0,2) != '61' || number.length < 11) { //If number doesn't start with 61 or length is less than 11
g_form.showFieldMessage('pass_variable_name_here', 'pass message here', 'error');
g_form.clearValue('pass_variable_name_here');
}
}

 


2.) You can create a validation regex for a phone number in "Variable validation regex" under the catalog variables module in the Application Navigator and You can apply that regex in the variable record "Type specifications" tab

 

If I could help you with my response you can mark it as helpful and correct as it benefits future viewers
Thanks,
Sai Kumar B
Community Rising Star 2023 & 2022