what is the code of only accept numerics only 10 digits
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-09-2017 10:22 PM
what is the code of only accept numerics only 10 digits
if end user tries to enter the alphabets it show one message it accepts only numerics

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-09-2017 10:25 PM
Hello Kishore,
Refer the below links may helpful to you.
Add a Phone number field. It should accept 10 digits (numeric) and can't be left alone.
Can i force a from field to only accept numeric value?
ServiceNow Commnunity MVP -2018 class.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-09-2017 10:26 PM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-09-2017 10:26 PM
Hi Kishore,
These below links will help you to create your query:
String field to accept only numeric values
Can i force a from field to only accept numeric value?
Please mark Helpful or Correct as per impact of the response!!
Thanks,
Anjali
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-09-2017 10:28 PM
Hi Kishore,
You can try the below code in your client script :
var val = g_form.getValue('<name_of_variable>');
// regex to allow only 10 numeric digits
if(!/^\d{10}$/.test(val)) {
alert('Only 10 numeric digits allowed');
return false;
}
I haven't tested the code but it should work fine.
Thanks,
Mohammed Zeeshan