Regx for the currency up two decimal point in JavaScript

Home Forums Web Development HTML, JavaScript and CSS Regx for the currency up two decimal point in JavaScript

Tagged: 

This topic contains 0 replies, has 2 voices, and was last updated by  Hirendra Sisodiya 4 years, 2 months ago.

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

    Pavan
    Moderator

    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.