JS 跨页面验证非空 问题: A页面通过<iframe>引入B页面 ,现在想通过A页面提交表单时验证B页面的文本框非空;如何实现!求实例: 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 A页面验证函数里可以这么获取Bwindows.frame['b'].document.getElementById('#B页面某个标签的ID') 不好意思,更正一下:windows.frame['b'].改为:windows.frames['b'].例子如下:a.htm为:<script>window.onload=function(){document.getElementById('bt').onclick=function(){alert(window.frames['b'].document.getElementById('b').value);}}</script><iframe src="b.htm" id="b" name="b"></iframe><input type="button" id="bt" value="tijiao">b.htm为:<input type="text" value="bbbccc" id="b">结果:在a.htm里点击提交按钮;警告b.htm里的id为B的VALUE值BBBCCC 如果要判断非空就改改a.htm就可以了,如下:<script>window.onload=function(){document.getElementById('bt').onclick=function(){ if(window.frames['b'].document.getElementById('b').value=="") {alert('b.htm里id为b的value值为空!');} else {alert('非空');} }}</script><iframe src="b.htm" id="b" name="b"></iframe><input type="button" id="bt" value="tijiao">//在框架里的文本框里面输入值试试! var b= window.frames['ad_cn1'].document.getElementById('txt1').value;为什么不可以进行赋值判断啊,当TXT1为空的时候正常,当有值的时候报var b= window.frames['ad_cn1'].document.getElementById('txt1').value;不支持此属性或方法;有解决办法吗 报缺少对象;var tt=window.frames['ad_cn1'].document.getElementById('txt1').value; if(tt==null||tt==""){ top就行了!top.document.getElementById("txtInput01") 就能获取父页面元素 反过来也一样 ls几位已经给出答案了 那个TXT1是个上传类型;<input type="file" name="txt1" id="txt1">没值的时候可以正常判断,当上传有值时,报window.frames['ad_cn1'].document.getElementById('txt1').value缺少对象; 是这样的,JS里先验证B页面的非空,然后还有本页面的验证;结果现在是B页面验证的同时也验证了A页面;想在验证B不成功就返回FALSE;不进行A页面验证;如果做... 代码说话:看清楚了B没有做选择就直接返回!而不继续验证下面A部分的!<script>function check(){ if(window.frames['b'].document.getElementById('txt').value=="") { alert('b.htm里id为b的value值为空!'); return false;//这个很关键,这个失败了也就不继续向下运行代码了! } //以下部分这里放其他验证代码 } </script><form name="frm" action="" onsubmit="return check()"><iframe src="b.htm" id="b" name="b"></iframe><input type="submit" id="bt" value="tijiao"></form> 我是这样来验证的,但是,一但上传文件有值后,就报运行时间错误,缺少对象window.frames['ad_cn1'].document.getElementById('txt1').value==""这句它不认识了又。 非常感谢falizixun2 不是它的问题了。是因为上传成功后返回的是文本那个上传它找不到所以报错了; JS如何调用其它网站的页面? 模式对话框返回值问题,谁能帮帮我? form提交到iframe的问题,头都大了 初学jsp,请问它有没有类似msdn的东西?请告诉我在哪下载! 保存图片 和 控制子窗体 的问题!!! 十万火急~~~~~~~~~~~~~~~~~~~ 请教关于动态加载树型菜单的问题! 在一个窗口中有三个iFrame ,在一个iframe中怎么打印另一个iframe,谢谢! 谁有右拉菜单的源代码? WEB SERVICE 一问。(欢迎参与) 返回顶部按钮,固定于页面右下角,并且在footer以上 如何使input失去焦点? MAP ABC 经纬坐标定点
a.htm为:<script>
window.onload=function(){
document.getElementById('bt').onclick=function(){alert(window.frames['b'].document.getElementById('b').value);}
}
</script>
<iframe src="b.htm" id="b" name="b"></iframe>
<input type="button" id="bt" value="tijiao">b.htm为:
<input type="text" value="bbbccc" id="b">结果:在a.htm里点击提交按钮;警告b.htm里的id为B的VALUE值BBBCCC
<script>
window.onload=function(){
document.getElementById('bt').onclick=function(){
if(window.frames['b'].document.getElementById('b').value=="")
{alert('b.htm里id为b的value值为空!');}
else
{alert('非空');}
}
}
</script>
<iframe src="b.htm" id="b" name="b"></iframe>
<input type="button" id="bt" value="tijiao">//在框架里的文本框里面输入值试试!
报var b= window.frames['ad_cn1'].document.getElementById('txt1').value;不支持此属性或方法;有解决办法吗
top.document.getElementById("txtInput01") 就能获取父页面元素 反过来也一样 ls几位已经给出答案了
<input type="file" name="txt1" id="txt1">
没值的时候可以正常判断,当上传有值时,报window.frames['ad_cn1'].document.getElementById('txt1').value缺少对象;
结果现在是B页面验证的同时也验证了A页面;
想在验证B不成功就返回FALSE;不进行A页面验证;如果做...
<script>
function check(){
if(window.frames['b'].document.getElementById('txt').value=="")
{
alert('b.htm里id为b的value值为空!');
return false;//这个很关键,这个失败了也就不继续向下运行代码了!
}
//以下部分这里放其他验证代码
}
</script>
<form name="frm" action="" onsubmit="return check()">
<iframe src="b.htm" id="b" name="b"></iframe>
<input type="submit" id="bt" value="tijiao">
</form>
那个上传它找不到所以报错了;