- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-19-2019 09:22 PM
Hello.
I created a variable to get the user to enter a phone number.
I would like to limit this variable as below.
・Only half-width numbers numbers can be entered.
・Set the maximum number of characters
Now, i set 'type' to 'Single Line Text' so should I change type too?
I appreciate it if you could answer.
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-19-2019 10:28 PM
Hi,
Please try with below solution:
Please write this code to you catalog Client Script
function onChange(control, oldValue, newValue, isLoading, isTemplate)
{
if(isLoading || newValue==='')
{
g_form.showFieldMsg('mobile_no','number starting from 9/8/7 are valid','info'); //here mobile_no is your variable name
return;
}
var phone = /^[789][0-9]{9}/;
if(!phone.test(newValue)&& newValue!='')
{
g_form.setValue('mobile_no','');
g_form.showFieldMsg('mobile_no','Please enter 10 digitvalid mobile number','error');
}
}
Regards,
Sanket
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-19-2019 11:22 PM
It doesn't work and Sorry I forgot to tell.
I created new field on the sn_customerservice_case to record to put the phone
number entered in the variable on the portal and the new filed type is 'String'
Also, the variable on record producer check 'Map to field'.
I don’t know if that ’s the case, u_phone_number is displayed as variable name.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-19-2019 11:29 PM
modify the below line ,
var phone = g_form.getValue('u_phone_number');
you will use the variable name "u_phone_number" instead of "number"

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-19-2019 10:28 PM
Hi,
Please try with below solution:
Please write this code to you catalog Client Script
function onChange(control, oldValue, newValue, isLoading, isTemplate)
{
if(isLoading || newValue==='')
{
g_form.showFieldMsg('mobile_no','number starting from 9/8/7 are valid','info'); //here mobile_no is your variable name
return;
}
var phone = /^[789][0-9]{9}/;
if(!phone.test(newValue)&& newValue!='')
{
g_form.setValue('mobile_no','');
g_form.showFieldMsg('mobile_no','Please enter 10 digitvalid mobile number','error');
}
}
Regards,
Sanket