Join the #BuildWithBuildAgent Challenge! Get recognized, earn exclusive swag, and inspire the ServiceNow Community with what you can build using Build Agent.  Join the Challenge.

Number formatting

Winnie P
Mega Sage

Hello Team - I am creating a Catalog Item and will add a question for requester's to provide an account number of some sort.  How do I configure this to check for proper number formatting? Account number maybe something like 00-0000-0000-00 blah blah.  What is the easiest, best practice option to do so please?  Thank you.

1 ACCEPTED SOLUTION

If you don't have any experience with scripting, recommend creating a Variable Validation Regex because there's no scripting.

Since it's customer number, you'll probably use it more then 1 form?

To create and use Variable Validation Regex.

1. From Navigator, search "Regex". Select "Variable Validation Regex" and then "New" button.

find_real_file.png

2. Enter as in the following and select "Submit" to save.

find_real_file.png

3. Open your form. Open the variable "customer number". Select the "Type Specifications" tab. Select "Customer Number" as Validation Regex.

find_real_file.png

View solution in original post

16 REPLIES 16

Such functionality might be available but right now I don't know that. 

Hi,

Do we need follow-up on this?

If this has resolved kindly mark this as correct and close the thread so others will refer same in future.

Thanks,

Dhananjay

If you don't have any experience with scripting, recommend creating a Variable Validation Regex because there's no scripting.

Since it's customer number, you'll probably use it more then 1 form?

To create and use Variable Validation Regex.

1. From Navigator, search "Regex". Select "Variable Validation Regex" and then "New" button.

find_real_file.png

2. Enter as in the following and select "Submit" to save.

find_real_file.png

3. Open your form. Open the variable "customer number". Select the "Type Specifications" tab. Select "Customer Number" as Validation Regex.

find_real_file.png

Great, thank you Hozawa, this way is easy. Is there a way to stop customers from submitting the request if number is re-entered incorrectly ie, the request will still be able to be submitted:

find_real_file.png

Hi, For this you need onSubmit catalog client script. var val=g_form.getValue('account_no'); // change name of variable here alert(val); var pattern= /\d{2}-\d{4}-\d{4}-\d{2}/; if(val.search(pattern)==-1) { alert("Incorrect account no, please enter correct one"); g_form.clearValue('account_no'); // change name of variable here. return false; } else{ alert("correct account no"); } Thanks, Dhananjay