javascript 验证文本框不能为空` 好奇怪啊`怎么不触发onsubmit事件啊`` 在线等``
<script laungage= "javascript ">
function check()
{ var user_name=document.getElementById( "username ").value
var pwd=document.getElementById( "pwd ").value
if (user_name.value== " ")
{
alert( "用户名不能为空! ");
from1. username.focus();
return false;
}
if (pwd.value== " ")
{
alert( "密码不能为空! ");
return false;
}
}
</script>
<form id= "form1 " name= "form1 " method= "post " action= "4.jsp " onsubmit= "return check() ">
------解决方案-------------------- <script laungage= "javascript ">
function check()
{ var user_name=document.getElementById( "username ").value
var pwd=document.getElementById( "pwd ").value
if (user_name.value== " ")
{
alert( "用户名不能为空! ");
from1. username.focus();//这里的from1是什么?还为指定对象吧?
------解决方案--------------------看看脚本有没有出错啊
如果出错了就不往下执行了