onclick="return check()"和onclick="check()"区别
秦时明月之君临天下:
看到这篇文章,我试了下,onclick()是写在submit里面,js处了判断是否为空,还用了console.log(if条件),在if判断语句后面打印判断语句,结果就让我蒙了,返回false,但是表单提交了?你好,请问你知道这是怎么回事吗?
[code=html]
//js
function isSubmit(){
var username = document.getElementById("username").value;
var password = document.getElementById("password").value;
if (username!="" && password!="") {
console.log(username!="" && password!="");
return true;
}else{
console.log(username!="" && password!="");
confirm("账号或密码为空,请填写完整");
return false;
}
}
//截取的HTML
[/code]
|