How to restrict numeric and special characters and allowing rules- only alphabets and _(under score) only ? please help me

ram_sn2018
Kilo Contributor

How to restrict  numeric and  special characters  and allowing  rules- only alphabets and _(under score) only ? please help me, we have project requirement.

 

 

 

 

 

Thanks,

Ram

1 ACCEPTED SOLUTION

Ankur Bawiskar
Tera Patron
Tera Patron

Hi Ram,

so only alphabets a to z lowercase and A to Z uppercase and only 1 special character i.e. underscore is allowed.

use this script in client side

I believe this you want in onchange client script

function onChange(control, oldValue, newValue, isLoading, isTemplate) {
if (isLoading || newValue === '') {
return;
}

if(!/^[a-zA-Z_]+$/i.test(newValue)){
alert('Please enter only upper/lower case alphanumeric & underscore character');

g_form.clearValue('fieldName');

}

}

Mark Correct if this solves your issue and also mark Helpful if you find my response worthy based on the impact.
Thanks
Ankur

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

View solution in original post

2 REPLIES 2

Ankur Bawiskar
Tera Patron
Tera Patron

Hi Ram,

so only alphabets a to z lowercase and A to Z uppercase and only 1 special character i.e. underscore is allowed.

use this script in client side

I believe this you want in onchange client script

function onChange(control, oldValue, newValue, isLoading, isTemplate) {
if (isLoading || newValue === '') {
return;
}

if(!/^[a-zA-Z_]+$/i.test(newValue)){
alert('Please enter only upper/lower case alphanumeric & underscore character');

g_form.clearValue('fieldName');

}

}

Mark Correct if this solves your issue and also mark Helpful if you find my response worthy based on the impact.
Thanks
Ankur

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

Ankur Bawiskar
Tera Patron
Tera Patron

Hi Ram,

Can you also mark my answer as helpful.

Regards

Ankur

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader