Regx for the currency up two decimal point in JavaScript

Tagged: 

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #4932
    Pavan
    Member

    I need to write the function to check whether the input value is in currency or not. I know that I can use the regular expression in the JavaScript function.

    Please help to write this.

    #4933

    you can validate the input string as decimal up to two numbers like:

    function j_is_Currency(s)
    {
     var pat = /^[$]?\d{1,10}([.]\d{2})?$/; 
     
     if (s.length > 0) 
     {
      var matchArr = s.match(pat);
      if(matchArr==null)
       return false;
     }
     return true;
    }
Viewing 2 posts - 1 through 2 (of 2 total)
  • You must be logged in to reply to this topic.