日期:2014-05-16 浏览次数:20364 次
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> </head> <body> <input type='text' onkeyup='tes(this)' /> <script type="text/javascript"> var exs = ""; var pt1 = /^\d{0,5}$/; var pt2 = /^\d{0,5}\.\d{0,2}$/; function tes(obj){ if(obj.value.length<=5){ if(pt1.exec(obj.value)!=null){ exs = obj.value; }else{ obj.value=exs; } }else{ if(pt2.exec(obj.value)!=null){ exs = obj.value; }else{ obj.value=exs; } } } </script> </body> </html>