Currency validation

niharikayb
Kilo Contributor

HI,

Can anyone please suggest the validation for 00,000,000,000.00 on the client script

Thanks in advance,

Niharika

5 REPLIES 5

Ankur Bawiskar
Tera Patron
Tera Patron

Hi Niharika,



What is your exact requirement?


What validation you want to do and against what?


Can you explain in detail.



Regards


Ankur


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

Hi Ankur ,



    we have a string type variable on catalog item where we want currency validation.The format should be like 00,000,000.00 .



When the user enters the amount in the wrong format ,there should be an alert


Hi Niharika,



you will have to use regular expression for this



Regards


Ankur


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

Hi Niharika,



Following is the code which contains the Regular Expression. It matches strings such as 00,000,000,000.00 i.e. 2 digits,3digits,3digits,3digits then dot and 2 zeros



var costcenter = "01,000,123,133.00";


var validate1 = new RegExp('[0-9]{2},[0-9]{3},[0-9]{3},[0-9]{3}.00$');  


var result = validate1.test(costcenter);


gs.print(result);



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


Thanks


Ankur


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