<!doctype html> <html> <head> <meta charset="utf-8"> <style type="text/css"> #switcher input{height:26px;width:200px;} </style> <script src="./jquery.js"></script> <script type="text/javascript"> $(document).ready(function(){ $("#switcher input").keypress(function(event){ if(event.which && (event.which < 48 || event.which >57)){ event.preventDefault(); } }); }); </script> </head> <body> <div id="switcher"> <input type="text" value="只能输入数字的输入掩码技术" id="txt" maxlength="150" name="txtname" onfocus="this.value=(this.value==‘只能输入数字的输入掩码技术‘) ? ‘‘ : this.value;" onblur="this.value=(this.value==‘‘) ? ‘只能输入数字的输入掩码技术‘ : this.value;"/> </div> </body> </html>
所谓输入掩码技术,即只有数字键起作用,布布扣,bubuko.com
时间: 2024-10-07 05:22:40