有小问题不懂,请各位大虾指点 function check() { if(document.getElementById("txt_code").value=="") { alert("单号不能为空,请填写!"); return false; } else { document.getElementById("txt_code").value="123456"; }} 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 如果是调用其他的function呢?如果单号不为空,则执行,否则不执行 if(document.getElementById("txt_code").value=="") { alert("单号不能为空,请填写!"); return false; } else { //document.getElementById("txt_code").value="123456"; 换成你要调用的function test(); } 不好意思 ,是这样的:function check() { if(document.getElementById("txt_code").value=="") {alert("单号不能为空,请填写!"); return false; } if(document.getElementById("txt_nmae").value=="") {alert("名称不能为空,请填写!"); return false; } } //////////////////////// function pp() { check(); document.getElementById("txt_code").value="123456"; return false; } 如果这样写,不管单号或名称是否为空,都会继续执行document.getElementById("txt_code").value="123456"; 如何怎么写才能当check()条件不满足时不执行document.getElementById("txt_code").value="123456";否则执行 加个判断呗 把pp()改一下function pp() { if(check()!=false){ document.getElementById("txt_code").value="123456"; return false; }} this?<html><head><meta http-equiv="Content-Type" content="text/html; charset=gb2312"><title>新建网页 1</title></head><body><input id="txt_code" onblur="pp(this)"> <script language="javascript"><!--function check() { if(document.getElementById("txt_code").value==""){ return false; } return true } function pp(obj){ if(!check()){ alert("单号不能为空,请填写!") return obj.focus() } else{ newFun()}}function newFun(){ document.getElementById("txt_code").value="123456";}//--></script></body></html> 问这样很有意思的.我在想,你写code 多长时间了. 设为首页,chrome浏览器无法执行,该怎么办 如何通过javascript修改xml里节点的属性值??急!! 如何将sql的text字体的内容按原样显示在textarea? 小女子求一段代码,大哥哥,大姐姐来帮帮忙,谢谢了先!在线等!!~ 如何添加换行 几个非常急的javaScript小问题????????????????? 用ScriptX打印的奇怪问题! 在提交前获取radio的值作为附带参数怎么写呢?谢谢 javascript高手请进!!! 高分求解:用javascript 来限制表单中 input 格式的问题 首页加载div层弹出窗口的问题 用js赋值后的div的怎么求高
如果单号不为空,则执行,否则不执行
{
alert("单号不能为空,请填写!");
return false;
}
else
{
//document.getElementById("txt_code").value="123456"; 换成你要调用的function
test();
}
function check()
{
if(document.getElementById("txt_code").value=="")
{alert("单号不能为空,请填写!");
return false;
}
if(document.getElementById("txt_nmae").value=="")
{alert("名称不能为空,请填写!");
return false;
}
}
////////////////////////
function pp()
{
check();
document.getElementById("txt_code").value="123456";
return false;
}
如果这样写,不管单号或名称是否为空,都会继续执行document.getElementById("txt_code").value="123456";
如何怎么写才能当check()条件不满足时不执行document.getElementById("txt_code").value="123456";否则执行
{
if(check()!=false){
document.getElementById("txt_code").value="123456";
return false;
}
}
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>新建网页 1</title>
</head><body>
<input id="txt_code" onblur="pp(this)">
<script language="javascript">
<!--
function check() {
if(document.getElementById("txt_code").value==""){
return false;
}
return true
} function pp(obj){
if(!check()){
alert("单号不能为空,请填写!")
return obj.focus()
}
else{ newFun()}
}function newFun(){
document.getElementById("txt_code").value="123456";
}
//-->
</script>
</body>
</html>
我在想,你写code 多长时间了.