php提交表单调用js验证是否为空不起作用
<scriptlanguage="javascript">functionCheckForm(){if(document.getElementById('card_sn'...
<script language="javascript">
function CheckForm()
{
if(document.getElementById('card_sn').value=="")
{
alert('请输入卡号!');
document.getElementById('card_sn').focus();
return false;
}
if(document.getElementById('card_password').value=="")
{
alert('请输入密码!');
document.getElementById('card_password').focus();
return false;
}
return true;
}
</script>
<form method="get" name="form1" action="card_list2.php" onsubmit="return CheckForm();">
<tr>
<td width="107" class="tb_zi1">卡号:</td>
<td width="203"><label>
<input type="text" name="card_sn" class="tab_inc"/>
</label></td>
<td width="106" class="tb_zi1">密码:</td>
<td width="196"><input type="password" name="card_password" class="tab_inc"/></td>
<td width="89"><label>
<input type="submit" name="Submit" value="查询" />
</label></td>
</tr>
</form>
点击查询按钮后没有经过js函数做验证,为空的时候点击没反应 展开
function CheckForm()
{
if(document.getElementById('card_sn').value=="")
{
alert('请输入卡号!');
document.getElementById('card_sn').focus();
return false;
}
if(document.getElementById('card_password').value=="")
{
alert('请输入密码!');
document.getElementById('card_password').focus();
return false;
}
return true;
}
</script>
<form method="get" name="form1" action="card_list2.php" onsubmit="return CheckForm();">
<tr>
<td width="107" class="tb_zi1">卡号:</td>
<td width="203"><label>
<input type="text" name="card_sn" class="tab_inc"/>
</label></td>
<td width="106" class="tb_zi1">密码:</td>
<td width="196"><input type="password" name="card_password" class="tab_inc"/></td>
<td width="89"><label>
<input type="submit" name="Submit" value="查询" />
</label></td>
</tr>
</form>
点击查询按钮后没有经过js函数做验证,为空的时候点击没反应 展开
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询