Regx help

Saai1
Tera Expert

Hi Everyone,

 

Need help in client script regex to allow only number form range 1 to 50000 in a single line text field.

 

Here is the regex I'm using and it is not working as expected. It allows till 50009. I want till 50000 only.

^(?:[1-9][0-9]?[0-9]?[0-9]?[0-9]?|1[1-5][0-9]?[0-9]?[0-9]?[0-9]?|2[0-4][0-9]?[0-9]?[0-9]?[0-9]?|25[0-5][0-9]?[0-9]?[0-9]?|6[0-4][0-9]?[0-9]?[0-9]?[0-9]?|50000)$

 

Thanks,

 

1 ACCEPTED SOLUTION

This is working.

 

/^([1-9]|[1-9][0-9]|[1-9][0-9]{2}|[1-9][0-9]{3}|[1-5][0-9]{4}|6[0-4][0-9]{3}|65000)$/;

View solution in original post

13 REPLIES 13

Hemant Goldar
Mega Sage
Mega Sage

Hi @Saai1 ,

please use the below regex code.
/^(?:[1-9]\d{0,4}|50000)$/

 

I hope this helps!

 

Regards,

Hemant 

**Please mark the appropriate response as correct answer and helpful, This may help other community users to follow correct solution.**

Hello,

 

It is still allowing 50001 till 50009. I want till 50000 only.

try the below code,


/^(?!5000[1-9]|[5-9]\d{4}|[1-9]\d{5,})\d{1,5}$|^50000$/

 

I hope this helps,

 

Thanks,

Hemant

This works fine but it should not allow 0.

 

Also, I have one more requirement that should allow from 1 to 65000 numbers only.