1

Here is my code i have tried this but i didn't get the proper output. I want to give input like 10.00,100.00,1,000.00,10,000.00 How to validate this

<input type="text" name="depo_amt" id="depo_amt"  maxlength="70" placeholder="10.00"onclick="formatNumber()"/>`

function formatNumber()
        {
         var regex  = ^[0-9]\d{0,9}(\.\d{1,2})?%?$;

                if (depo_amount.value=='regex')
                          {
                              alert("Number is valid");
                               return false;
                         }
else
{
alert("Number is not valid");
}

}

user3422452
  • 57
  • 1
  • 2
  • 5

2 Answers2

2

this regex will do that for you

^[1-9]\d{0,2}(,\d{3})*\.\d{2}$

http://regex101.com/r/uY3fS5

Lodewijk Bogaards
  • 19,777
  • 3
  • 28
  • 52
1

this will work hopefully..

please check and tell if anyone finds any descipancy

^[1-9]\d{0,2}(?:,\d\d\d)*\.\d{2}$

http://regex101.com/r/dS1zZ0

Lodewijk Bogaards
  • 19,777
  • 3
  • 28
  • 52
aelor
  • 10,892
  • 3
  • 32
  • 48