How to not allow any spaces after the text in a variable

Archana23
Tera Contributor

How to not allow any spaces after the text in a variable

4 REPLIES 4

SAI VENKATESH
Tera Sage
Tera Sage

Hi @Archana23 

 

You can check out the below Link 

 

https://www.servicenow.com/community/developer-forum/can-we-restrict-spaces-to-be-enter-in-a-field/m...

 

Thanks and Regards

Sai Venkatesh

Anurag Tripathi
Mega Patron
Mega Patron

Hi,

You can write an onchange client script and trim the leading and trailing spaces, if any.

Here is an eg.

 

    var str = g_form.getValue('<variable_name>');
        var wsr = str.trim();
        g_form.setValue('variable_name',wsr );

 

-Anurag

Hi @Anurag Tripathi Thanks for your reply.

 

I tried the above script and it is accepting the spaces 

It will accept the space but remove it when you save the form.

-Anurag