输入电话号码
<!doctype html> <html lang="en"> <head> <meta charset="UTF-8"> <title>Document</title> </head> <body> 手机号码:<input type="text" id="txt" maxlength="11" onkeypress="ttt(this,event)"> <script> function ttt(obj,ev){ if(ev.keyCode<48||ev.keyCode>57){ ev.preventDefault(); } } </script> </body> </html>
只能阻止键盘输入