请问这段js程序,检查输入是否非空,为什么没起作用?
<script type="text/javascript"> function check(){ var x=document.getElementsByName("username").value; if(x==null || x==""){ alert("Please input username"); return false; } } </script></head> <body> <form action="js.php" method="POST" onsubmit="return check()"> <input type="text" name="username"></input> <input type="submit" name="sub"></input> </form> </body>var ctrip = document.getElememntsByName("optctr_ip")[0].value;