怎么实现超级连接提交表单且验证提交的内容 怎么实现超级连接提交表单且验证提交的内容 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 用formObj.submit();示例:<form id="form1">....</form><a href="javascript:;" onclick="document.getElementById('form1').submit()">提交表单</a> 这样?<script type="text/javascript"><!-- function kkk(){ var obj = document.getElementById('form1'); if (obj.kk.value==""){ alert("kk为空"); return ; } obj.submit(); }//--></script> <body> <form method="post" action="" name="form1" id="form1"> <input type="text" name="kk"> <a href="#" onclick="kkk()">提交</a> </form> </body> <script type="text/javascript">function submitvialink() { //客户端验证表单的代码 //假设checkFlag变量保存验证结果是否通过 if (checkFlag) document.form.submit(); else return false;}</script><a href="javascript:submitvialink();">submit</a> <form name="frm" method="get" action="news/WriteData.asp"> <tr> <td width="90px"><input type="text" id="time" name="time"></td> <td width="80px"><!--#include file="news/area.asp"--></td> <td width="160px"><!--#include file="news/customer.asp"--></td> <td width="350px"><textarea rows="5" id="content" name="content"></textarea></td> <td width="90px"><select><option>数据绑定</option></select></td> <td width="90px"><a href="#" onclick="ok()">添加</a> </td> </tr> </form>function ok(){ if(document.getElementById("time").value=="") { alert("请输入时间!"); return ; } if(document.getElementById("province").value=="0") { alert("请选择省"); return ; } if(document.getElementById("types").value=="0") { alert("请选择客户类型"); return ; } if(document.getElementById("txtSearch").value=="") { alert("请输入客户名"); return ; } if(document.getElementById("content").value=="") { alert("请填写工作内容"); return ; } document.frm.submit();}我现在是希望把ok这一部分分成2个函数,即一个验证函数,一个提交函数,假如验证函数是这样的function checkForm(){ if(document.getElementById("time").value=="") { alert("请输入时间!"); return false; } if(document.getElementById("province").value=="0") { alert("请选择省"); return false; } if(document.getElementById("types").value=="0") { alert("请选择客户类型"); return false; } if(document.getElementById("txtSearch").value=="") { alert("请输入客户名"); return false; } if(document.getElementById("content").value=="") { alert("请填写工作内容"); return false; } }那么那个ok()函数怎么写? 这样声明的两个javascript对象的属性会不会不同? *********隐藏弹出窗口菜单栏和地址栏******** jquery 请教return false的用法 求js的邮箱格式正则表达式 【求助】页面位置怎么跳到生成的html位置 js写树的时候出现运行缓慢,是否继续运行脚本的提示框.请问..有谁能解决这个问题吗. 深夜问题,快来回答啊,很简单,我不懂js cookie??? request 未定义是怎么回事啊 addEvent addClass初始化问题 关于百度弹出层popup.js的问题,路过的看下,谢谢~~~~~
formObj.submit();示例:
<form id="form1">
....
</form><a href="javascript:;" onclick="document.getElementById('form1').submit()">提交表单</a>
<script type="text/javascript">
<!--
function kkk(){
var obj = document.getElementById('form1');
if (obj.kk.value==""){
alert("kk为空");
return ;
}
obj.submit();
}//-->
</script>
<body>
<form method="post" action="" name="form1" id="form1">
<input type="text" name="kk">
<a href="#" onclick="kkk()">提交</a>
</form>
</body>
function submitvialink() {
//客户端验证表单的代码
//假设checkFlag变量保存验证结果是否通过
if (checkFlag) document.form.submit();
else return false;
}
</script>
<a href="javascript:submitvialink();">submit</a>
<form name="frm" method="get" action="news/WriteData.asp">
<tr>
<td width="90px"><input type="text" id="time" name="time"></td>
<td width="80px"><!--#include file="news/area.asp"--></td>
<td width="160px"><!--#include file="news/customer.asp"--></td>
<td width="350px"><textarea rows="5" id="content" name="content"></textarea></td>
<td width="90px"><select><option>数据绑定</option></select></td>
<td width="90px"><a href="#" onclick="ok()">添加</a>
</td>
</tr>
</form>
function ok()
{
if(document.getElementById("time").value=="")
{
alert("请输入时间!");
return ;
}
if(document.getElementById("province").value=="0")
{
alert("请选择省");
return ;
}
if(document.getElementById("types").value=="0")
{
alert("请选择客户类型");
return ;
}
if(document.getElementById("txtSearch").value=="")
{
alert("请输入客户名");
return ;
}
if(document.getElementById("content").value=="")
{
alert("请填写工作内容");
return ;
}
document.frm.submit();
}我现在是希望把ok这一部分分成2个函数,即一个验证函数,一个提交函数,假如验证函数是这样的
function checkForm()
{
if(document.getElementById("time").value=="")
{
alert("请输入时间!");
return false;
}
if(document.getElementById("province").value=="0")
{
alert("请选择省");
return false;
}
if(document.getElementById("types").value=="0")
{
alert("请选择客户类型");
return false;
}
if(document.getElementById("txtSearch").value=="")
{
alert("请输入客户名");
return false;
}
if(document.getElementById("content").value=="")
{
alert("请填写工作内容");
return false;
}
}
那么那个ok()函数怎么写?