Regular expression to check the currency upto 2 digit in JavaScript

 
Regular expression to check the currency upto 2 digit in JavaScript such as 34, 45.45, 567.45 etc.

    <html>  
      <head>  
          <script type="text/javascript">  
          var reg = /^\d+(\.\d\d)?$/;  
          function CurrencyValidation(Currency)
          {  
            var OK = reg.exec(Currency.value);  
            if (!OK)  
              window.alert("Currency isn't  valid");  
            else  
              window.alert("Currency is  valid");  
          }  
        </script>  
      </head>  
 
      <body>  
        <p>Enter your Currency up to two decimal numbers and then press Enter.</p>  
        <form action="">  
          <input name="txtCurrency" onchange="CurrencyValidation(this);">  
        </form>  
      </body>  
    </html>

Author: Pavan

I am asp.net developer have good knowledge of Asp.net ver 05,08,10 and good hand in sql server.Proficient in Object Oriented Programming and javascript, jQuery. Achievements - Integrate Spotfire, appnexus API ASP.net with sql server. Hobbies - Blogging ,Games, Movies ,Teaching,Keeping myself update with new technologies