- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-15-2022 06:38 AM
I have a client script that allows only (-ve) numbers along with decimal values up to 2 places.
I want to allow users to use commas as well in place of decimal (dot) if they want.
I am using the below expression
var regexp = /^-[1-9][0-9]?(\.[0-9]{1,2})?$/;
How do I modify it so that it also accepts values like (10,11 ) as an alternative to (10.11)
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-15-2022 06:49 AM
Hi
your expression had an error when dealing with the starting "-" sign.
And the full expression is
^[-]?[1-9][0-9]?([\,\.]{1,1}[0-9]{1,2})?$
See https://regex101.com/r/hNF58f/1 if you want to play around
Maik
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-15-2022 06:49 AM
Hi
your expression had an error when dealing with the starting "-" sign.
And the full expression is
^[-]?[1-9][0-9]?([\,\.]{1,1}[0-9]{1,2})?$
See https://regex101.com/r/hNF58f/1 if you want to play around
Maik
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-15-2022 08:40 AM
Thanks