To restrict negative values in amount field.

Tarasingh26
Tera Expert

Hi All,

 

I have requirement to restrict user to enter negative value in amount field. I wrote on submit script which is working fine when I enter two digits or three digits   like 78 or 651 etc, But when I enter more than three digits, entered value comes with comma(,) and it is not working when comma is there in value (4,567).

 

In the attachment script is there , Please suggest solutions.

3 REPLIES 3

Community Alums
Not applicable

hi @Tarasingh26 ,

 

Can to pass attribute for the integer field's dictionary as format=none, so comma will not be shown.

 

Please mark the reply as helpful and solution

 

Thanks

Akash

Arnaud Derancou
Kilo Guru

Would that work before the if statement?

var amt1=parseInt(amt1.replace(',','');

 

 

Anurag Tripathi
Mega Patron
Mega Patron

Hi,

Check this article, this has all the validations using regex for Integer fields

How to allow integers in the string field for more... - ServiceNow Community

 

 

-Anurag