0
关于js验证输入框是否为空的疑问5
我在jsp页面中使用下面这个函数来验证对话框是否为空
function checkForm(){
if(document.form1.type.value=="")
{ form1.type.focus();
alert('该对话框不能为空);
return false;
}
}
<form name="form1" action="servlets/createservlet">
.
.
.
<input type="submit" name="submit" value="提交" onclick="checkForm()">
如果有对话框为空的话,js函数返回false,会弹出一个对话框提示你。
但是我点击“确定”后,为什么jsp页面上的数据还会被提交到servlet中去啊?
向各位大侠请教!!!!
document.form1.type???这里是不是有问题,如果这里报错,整个if语句都不执行,肯定不会return false
function checkForm(){