1 <input type="text" placeholder="请输入您的用户名..."> 2 <script type="text/javascript"> 3 $("input[name=‘username‘]").bind(‘input‘,function(){ 4 var pattern = new RegExp("[^a-zA-z1-9]"); 5 var rs = ‘‘; 6 var str = $(this).val(); 7 8 for (var i=0;i< str.length;++i){ 9 rs = rs + str.substr(i, 1).replace(pattern,‘‘); 10 } 11 12 $(this).val(rs); 13 }); 14 </script>
时间: 2024-10-06 01:11:48