<script type="text/javascript" language="java">
function check(){
var tname=document.form1.titlename.value;
var fpath=document.form1.filepath.value;
if(tname.length==""){
alert("二级标题不能为空!");
tname.focus(); 加入这句话跳出后面所有行,直接到ruturn true这行
return false;
}
if(fpath.length==""){
alert("文件地址不能为空!");
return false;
}
return true;
}
</script>为什么直接跳到return true这里呢,我是嵌入在jsp页面里的。
function check(){
var tname=document.getElementById('titlename');
var fpath=document.getElementById('filepath');
if(tname.value==""){
alert("二级标题不能为空!");
tname.focus(); 加入这句话跳出后面所有行,直接到ruturn true这行
return false;
}
if(fpath.value==""){
alert("文件地址不能为空!");
return false;
}
return true;
}只所以出问题,时因为不应该取它的值