- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-10-2023 08:00 PM
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
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-10-2023 11:49 PM - edited 03-10-2023 11:52 PM
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-10-2023 11:49 PM - edited 03-10-2023 11:52 PM
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