<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>Document</title> </head> <body> <script src="http://apps.bdimg.com/libs/jquery/1.9.1/jquery.min.js" type="text/javascript"></script> <script type="text/javascript"> function subname() { var str = $("#input").val(); var han = /^[\u4e00-\u9fa5]+$/; if (str == '') { alert("请输入汉字"); return false; }; if (!han.test(str)) { alert("不是汉字") return false; }; return true; }; </script> <form method="post" onsubmit="subname()"> <input type="text" id="input" value="" /> <button type="submit" id="btn">提交</button> </form> </body> </html>
效果图: