title: How to prevent keypress two digits after a decimal number?
body: <p>I have got a task to prevent keypress two digits after a decimal number.
   My jquery file is </p>
  
  <pre><code>$(function(){ 
      $('#name').bind('paste', function(){
      var self = this;
      setTimeout(function() {
          if(!/^[a-zA-Z]+$/.test($(self).val()))
              $(self).val('');
      }, 0);    
             }); 
  
          $('#salary').bind('paste', function(){
      var self = this;
      setTimeout(function() {
          if(!/^\d*(\.\d{1,2})+$/.test($(self).val()))
              $(self).val('');
      }, 0);    
             }); 
  
      $('.decimal').keyup(function(){
          var val = $(this).val();
          if(isNaN(val)){
               val = val.replace(/[^0-9]./g,'');
  
  
               if(val.split('.').length&gt;2) 
                   val =val.replace(/\.+$/,"");
          }
          $(this).val(val); 
      });
      });      
  </code></pre>
  
  <p>My html page is</p>
  
  <pre><code>&lt;b&gt;Name&lt;/b&gt;
  &lt;input type="text" id="name"  /&gt;&lt;br/&gt;
  &lt;b&gt;Salary&lt;/b&gt;
  &lt;input type="text" id="salary"  class="decimal" /&gt;
  </code></pre>
  
  <p>here i want only write 2 digits after decimal,how can i do this?
  You can see my code in <a href="http://jsfiddle.net/V6s4B/" rel="noreferrer">http://jsfiddle.net/V6s4B/</a></p>