The CreatorCon Call for Content is officially open! Get started here.

Validation regex for using in client script

Buddy 1
Tera Contributor

Hi,
How to validate a field which should accept only numbers with separators or decimals.
Eg: it should be like 0,00 or 0.00

Can someone help in the validation regex for this requirement. 

Thanks in advance!

1 ACCEPTED SOLUTION

@Buddy 1 ,

 

Try this and let me know:

/^[0-9]{1}[,.][0-9]{2}$/

 

Tried and tested for many use cases and seems it worked for me.

 

PRINCE_ARORA_0-1678951597498.png

 If my answer solved your issue, please mark my answer as Correct & 👍Helpful based on the Impact.

View solution in original post

7 REPLIES 7

Prince Arora
Tera Sage

@Buddy 1 

 

Can you try this:

 

/^[0]+([,.][0]{2})?$/

 

I have tested it works for me, please check and let me know if you have any issue:

PRINCE_ARORA_0-1678899571014.png

 

 If my answer solved your issue, please mark my answer as Correct & 👍Helpful based on the Impact.

Hi @Prince Arora ,

The example format is 0,00 or 0.00 but it can be also 1,12 or 2.13 .
Note: It can accept numbers.but the format is before separator or decimal allow only one digit and after separator or decimal allow only two digits 

Can you suggest?

Thanks in advance!

@Buddy 1 ,

 

Try this and let me know:

/^[0-9]{1}[,.][0-9]{2}$/

 

Tried and tested for many use cases and seems it worked for me.

 

PRINCE_ARORA_0-1678951597498.png

 If my answer solved your issue, please mark my answer as Correct & 👍Helpful based on the Impact.