Skip to content Skip to sidebar Skip to footer

Javascript Regular Expression To Allow Negative Double Value?

Hi I have e regular expression which helps me to validate user input. It only allows positive numbers with 2 decimal places, this is my regex: ^[0-9]+\.[0-9][0-9]$ I want this to

Solution 1:

It would be as follows:

^(\-)?[0-9]+\.[0-9][0-9]$

See working demo

Solution 2:

Think this will work:

^(-?)[0-9]+\.[0-9][0-9]$

Post a Comment for "Javascript Regular Expression To Allow Negative Double Value?"