js为什么验证为空却还是提交
写了这么个js验证txt中的文本为空时不提交的,可是倒是验证为空了,却还是提交,为什么呢<scriptlanguage="JavaScript"type="text/ja...
写了这么个js 验证txt中的文本为空时不提交的,可是倒是验证为空了,却还是提交,为什么呢
<script language="JavaScript" type="text/javascript">
function $(obj){
return document.getElementById(obj);
}
function check(){
if($("txt").value == "")
alert("为空");
}
</script>
</head>
<body>
<div id="send">
<form action="<?php echo $editFormAction; ?>" onsubmit="return check()" id="form1" name="send" method="POST">
<input name="submit" type="submit" value="send" />
<input name="chn" type="text" id="txt" value="" />
<input type="hidden" name="MM_insert" value="send" />
</form>
</div>
</body> 展开
<script language="JavaScript" type="text/javascript">
function $(obj){
return document.getElementById(obj);
}
function check(){
if($("txt").value == "")
alert("为空");
}
</script>
</head>
<body>
<div id="send">
<form action="<?php echo $editFormAction; ?>" onsubmit="return check()" id="form1" name="send" method="POST">
<input name="submit" type="submit" value="send" />
<input name="chn" type="text" id="txt" value="" />
<input type="hidden" name="MM_insert" value="send" />
</form>
</div>
</body> 展开
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询