How to prevent keypress two digits after a decimal number?
问题 I have got a task to prevent keypress two digits after a decimal number. My jquery file is $(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(/[