日期:2014-05-16 浏览次数:20600 次
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Test</title> <script type="text/javascript"> function beforeSubmit(form1){ if(form1.username.value==''){ alert('用户不能为空 !'); form1.username.focus(); return false; } if(form1.password.value==''){ alert('密码不能为空!'); form1.password.focus(); return false; } if(form1.password.value.length<6){ alert('密码至少为6位,请重新输入!'); form1.password.focus(); return false; } return true; } </script> </head> <form id="form1" onsubmit="beforeSubmit(this);"> 用户: <input type="text" id="username"/> <br /> 密码: <input type="password" id="password"/> <input type="submit" value="提交" /> </form> <body> </body> </html>
------解决方案--------------------
刚写错了,不是unicode编码,是16进制转换,比如alert("\u9ad8\u8d35\u6a58\u9ec4")