function check() {
if(Trim(document.reply.title.value) == "") {
alert("please intput the title!");
document.reply.title.focus();
//return false;
}
alert("please intput the content!");
if(Trim(document.reply.cont.value) == "") {
alert("please intput the content!");
document.reply.cont.focus();
return false;
}
return true;
}
javascript里面两个if,为什么只有当第一个if括号里面为true时,下面的语句才可以执行?
你下面的语句指什么,alert("please intput the content!");之后的?
就你这个代码是不是true都会执行下面的代码,
有个可能就是true不执行下面的,而不是执行下面的,为true会执行代码段,如果报错就不会继续执行了,而不是执行
看你段代码不管你第一个是不是true,都要执行下面的语句
if(Trim(document.reply.title.value) == "") {
alert("please intput the title!");
document.reply.title.focus();
//return false;
}
除非你这里的return false;不是注释掉的,
首先 第一个if就算执行了 第二个if条件只要成立也会执行 因为第一个执行后你并没有return掉 两个if没有直接关系 判断语句都写对了都会执行
其次 第一个执行后第二个不执行也是返回 true
第二个if不执行的时候你看看报错没
不知道是不是之前报错了,还是eclipse的问题,现在两个判断语句都可以判断到,谢谢各位