求助表单验证 for(var i=0;i<document.all.length;i++){if(document.all(i).type == 'text' && document.all(i).value == '') } 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 <html><head><meta http-equiv="Content-Type" content="text/html; charset=gb2312"><title>hehe</title><SCRIPT language=javascript>function check(){ for(var i=0;i<document.all.length;i++) { if(document.all(i).type == 'text' && document.all(i).value == '') alert("为空"); } } </SCRIPT></head><body topmargin="0" leftmargin="0"><form name="form1" method="post" action="" onSubmit="return check()"> <input type="text" name="textfield"> <input type="text" name="textfield2"> <input type="text" name="textfield3"> <input type="submit" name="Submit" value="提交"></form></body></html> function checkSubmit(){var Dates = "1234567890";for(i=0;i<document.form1.rand.value.length;i++){var CheckChar = document.form1.rand.value.charAt(i);if(Dates.indexOf(CheckChar)==-1){alert("验证码必须是数字!");return false;}}if((document.form1.ti.value)==''||(document.form1.ti.value)==null){window.alert("标题不能为空!");document.form1.ti.select();document.form1.ti.focus();return false;}if((document.form1.co.value)==''||(document.form1.co.value)==null){window.alert("内容不能为空!");document.form1.co.select();document.form1.co.focus();return false;}if((document.form1.rand.value)==''||(document.form1.rand.value)==null){window.alert("验证码不能为空!");document.form1.rand.select();document.form1.rand.focus();return false;}return true;}这个给你我以前写的 对你可能有用 改一下就行了 你是要学习吗?那我不凑热闹了。如果是实际使用我倒是写有一个专门用于判断form提交的文件。使用很方便。 楼上的可以发给我吗??你的判断form的文件,我想学学,谢谢~~ <html><head><meta http-equiv="Content-Type" content="text/html; charset=gb2312"><title>New Page 2</title></head><body><form name=frm>input1 **<input altStr="input1 description" ><br>input2 **<input altStr="input2 description" ><br>input3 **<input altStr="input3 description " ><br>input4 **<input altStr="input4 description" ><br>input5<input ><br>input6<input ><br><input type=button value=test onclick="checkAllNecessaryInputs(this.form);"><br></form></body></html><script>function checkAllNecessaryInputs(formObj){ if(formObj==null) formObj=document.forms[0]; var theElementsOfTheForm=formObj.elements; for (var i=0;i<theElementsOfTheForm.length;i++) { if((theElementsOfTheForm[i].altStr!=null) &&(theElementsOfTheForm[i].altStr!="") &&(theElementsOfTheForm[i].value=="") ) { alert("Please input :"+ theElementsOfTheForm[i].altStr); theElementsOfTheForm[i].focus(); return false; } } return true;}</script> 求一款flash音乐播放器,越简单越好。唯一的要求就是:能用JS获得当前播放状态:播放中,播放完毕。 求助,如何将此js改成“函数”方式的 同一页面两个表单的问题 js替换href 关于单选框验证对话框的问题 A页面JS调用B页面JS AB通过IFRAME嵌套 用js给Repeater控件里的复选框做全选 如何用js设置文本框的值 确定鼠标的位置以决定层的显示位置 关于SELECT!!! 如何判断一个OCX控件是否安装在客户端了 求各位大哥哥大姐姐帮帮忙
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>hehe</title>
<SCRIPT language=javascript>function check(){
for(var i=0;i<document.all.length;i++)
{
if(document.all(i).type == 'text' && document.all(i).value == '')
alert("为空");
}
} </SCRIPT>
</head>
<body topmargin="0" leftmargin="0">
<form name="form1" method="post" action="" onSubmit="return check()">
<input type="text" name="textfield">
<input type="text" name="textfield2">
<input type="text" name="textfield3">
<input type="submit" name="Submit" value="提交">
</form>
</body>
</html>
{
var Dates = "1234567890";
for(i=0;i<document.form1.rand.value.length;i++)
{
var CheckChar = document.form1.rand.value.charAt(i);
if(Dates.indexOf(CheckChar)==-1)
{
alert("验证码必须是数字!");
return false;
}
}
if((document.form1.ti.value)==''||(document.form1.ti.value)==null)
{
window.alert("标题不能为空!");
document.form1.ti.select();
document.form1.ti.focus();
return false;
}
if((document.form1.co.value)==''||(document.form1.co.value)==null)
{
window.alert("内容不能为空!");
document.form1.co.select();
document.form1.co.focus();
return false;
}
if((document.form1.rand.value)==''||(document.form1.rand.value)==null)
{
window.alert("验证码不能为空!");
document.form1.rand.select();
document.form1.rand.focus();
return false;
}return true;
}
这个给你我以前写的 对你可能有用 改一下就行了
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>New Page 2</title>
</head><body>
<form name=frm>
input1 **<input altStr="input1 description" ><br>
input2 **<input altStr="input2 description" ><br>
input3 **<input altStr="input3 description " ><br>
input4 **<input altStr="input4 description" ><br>
input5<input ><br>
input6<input ><br>
<input type=button value=test onclick="checkAllNecessaryInputs(this.form);"><br>
</form>
</body></html>
<script>
function checkAllNecessaryInputs(formObj)
{
if(formObj==null) formObj=document.forms[0];
var theElementsOfTheForm=formObj.elements;
for (var i=0;i<theElementsOfTheForm.length;i++)
{
if((theElementsOfTheForm[i].altStr!=null)
&&(theElementsOfTheForm[i].altStr!="")
&&(theElementsOfTheForm[i].value=="")
)
{
alert("Please input :"+ theElementsOfTheForm[i].altStr);
theElementsOfTheForm[i].focus();
return false;
}
}
return true;
}
</script>