js判断所有表单项不为空则提交表单
来源:互联网 发布:淘宝9.9包邮促销区 编辑:程序博客网 时间:2024/06/13 21:17
<span style="color: rgb(54, 46, 43); font-family: Arial; font-size: 14px; line-height: 26px;">demo1.html</span>
<span style="color: rgb(54, 46, 43); font-family: Arial; font-size: 14px; line-height: 26px;"></span><pre name="code" class="javascript"><html> <head> <title>提交表单页</title> <script type="text/javascript"> function myCheck() { for(var i=0;i<document.form1.elements.length-1;i++) { if(document.form1.elements[i].value=="") { alert("当前表单不能有空项"); document.form1.elements[i].focus(); return false; } } return true; } </script> </head> <body> <form name="form1" method="post" action="page2.html" onSubmit="return myCheck()"> 用户名:<input type="text" name="username"><br> 性别:<input type="text" name="sex"><br> 出生时间:<input type="text" name="birthday"><br> <input type="submit" value="提交"> </form> </body></html>
<span style="color: rgb(54, 46, 43); font-family: Arial; font-size: 14px; line-height: 26px;"></span>
<span style="color: rgb(54, 46, 43); font-family: Arial; font-size: 14px; line-height: 26px;"><span style="color: rgb(54, 46, 43); font-family: Arial; font-size: 14px; line-height: 26px;">demo2.html</span></span>
<span style="color: rgb(54, 46, 43); font-family: Arial; font-size: 14px; line-height: 26px;"><span style="color: rgb(54, 46, 43); font-family: Arial; font-size: 14px; line-height: 26px;"></span></span>
<span style="color: rgb(54, 46, 43); font-family: Arial; font-size: 14px; line-height: 26px;"><span style="color: rgb(54, 46, 43); font-family: Arial; font-size: 14px; line-height: 26px;"></span></span><pre name="code" class="javascript"><script language="Javascript"><!--function submit1(frm){ if (document.frm.word.value=="") { alert("请输入搜索新闻内容!");document.frm.word.focus();return false;}return true;} //--></script><form method="POST" action="" name="frm" onsubmit="return submit1(this);"><select name="select0"> <option value="0">请选择一个类别</option><option value="1">新闻</option><option value="2">产品</option><option value="3">留言</option></select><input type="text" name="word" size="20" class="input" style="height:19px; "><input type="radio" name="sea_cat" value="标题">标题 <input type="radio" name="sea_cat" value="内容">内容<input type="submit" value="搜" name="B1" class="input1" >
<span style="color: rgb(54, 46, 43); font-family: Arial; font-size: 14px; line-height: 26px;"><span style="color: rgb(54, 46, 43); font-family: Arial; font-size: 14px; line-height: 26px;"></span></span>
<span style="color: rgb(54, 46, 43); font-family: Arial; font-size: 14px; line-height: 26px;"><span style="color: rgb(54, 46, 43); font-family: Arial; font-size: 14px; line-height: 26px;"><span style="color: rgb(54, 46, 43); font-family: Arial; font-size: 14px; line-height: 26px;">demo3.html</span></span></span>
<span style="color: rgb(54, 46, 43); font-family: Arial; font-size: 14px; line-height: 26px;"><span style="color: rgb(54, 46, 43); font-family: Arial; font-size: 14px; line-height: 26px;"><span style="color: rgb(54, 46, 43); font-family: Arial; font-size: 14px; line-height: 26px;"></span></span></span>
<span style="color: rgb(54, 46, 43); font-family: Arial; font-size: 14px; line-height: 26px;"><span style="color: rgb(54, 46, 43); font-family: Arial; font-size: 14px; line-height: 26px;"><span style="color: rgb(54, 46, 43); font-family: Arial; font-size: 14px; line-height: 26px;"></span></span></span><pre name="code" class="javascript"><script type="text/javascript">function beforeSubmit(form){if(form.username.value==''){alert('用户名不能为空!');form.username.focus();return false;}if(form.password.value==''){alert('密码不能为空!');form.password.focus();return false;}if(form.password.value.length<6){alert('密码至少为6位,请重新输入!');form.password.focus();return false;}if(form.password.value!=form.password2.value) {alert('你两次输入的密码不一致,请重新输入!');form.password2.focus();return false;}return true;}</script><fieldset> <legend>用户注册</legend> <form method="post" name="form" action="user.do?method=register" onSubmit="return beforeSubmit(this);"> <table border="1" width="100%" cellspacing="0" cellpadding="0"> <tr><td><label>用户名:<input type="text" name="username" value=""></label></td></tr> <tr><td><label>密 码:<input type="password" name="password" value=""></label></td></tr> <tr><td><label>重复密码:<input type="password" name="password2" value=""></label></td></tr> <tr><td><input value="注册" type="submit"> <input type="reset" value="重置"></td></tr> </table> </form></fieldset>
<span style="color: rgb(54, 46, 43); font-family: Arial; font-size: 14px; line-height: 26px;"><span style="color: rgb(54, 46, 43); font-family: Arial; font-size: 14px; line-height: 26px;"><span style="color: rgb(54, 46, 43); font-family: Arial; font-size: 14px; line-height: 26px;"></span></span></span>
<span style="color: rgb(54, 46, 43); font-family: Arial; font-size: 14px; line-height: 26px;"><span style="color: rgb(54, 46, 43); font-family: Arial; font-size: 14px; line-height: 26px;"><span style="color: rgb(54, 46, 43); font-family: Arial; font-size: 14px; line-height: 26px;"></span></span></span>
0 0
- js判断所有表单项不为空则提交表单
- js判断所有表单项不为空则提交表单
- js判断所有表单项不为空则提交表单
- js判断表单提交是否为空
- js表单不为空才能提交
- 表单为空不提交
- 表单提交时判断所有控件不能为空
- js判断表单为空
- js判断提交的表单是否为空
- JS判断提交表单不能为空 等的验证
- 怎么控制提交的表单项不为空?
- Javascript 判断表单不为空
- JS判断表单输入是否为空
- JS判断表单输入是否为空
- js判断表单输入是否为空
- JS判断input表单是否为空
- js判断不提交表单方法
- js验证表单大全,用JS控制表单提交 ,javascript提交表单,表单提交 所有js判断
- 精简的约瑟夫环问题
- 2014/11/9 Python模块安装学习参考
- Strust2-----7、配置处理结果
- 数据结构树相关第二天-AVL二叉平衡搜索树
- 图片格式分析
- js判断所有表单项不为空则提交表单
- Atitit. Gui控件and面板----程序快速启动区--最佳实践Launchy ObjectDock-o0g
- Backbine.js实战第六章----视图
- 第四章 字符串和多为数组 思维导图
- Ubuntu 12.04.01 LTS 下ovs的安装与配置
- 【leetcode 单链表归并排序】Sort List
- VC设置监测内存泄露的方法
- 软件国际化之日期,数字,消息格式化
- Java异常处理