作家
登录

jquery 必填项判断表单是否为空的方法

作者: 来源:www.28hudong.com 2013-03-30 02:56:23 阅读 我要评论

html页面复制代码 代码如下:<form onsubmit="if(confirm('确定好你所填写的正确,不然会发错!')) {return checkForm();}else{return false;}" > <table > <tr> <td>选择发送人<font class="red">*</font></td> <td> <input type="text" name="sendto_type[]" id="sendto_type1" value="1" >按城市发送 </td> </tr> <tr> <td>选择发送人2<font class="red">*</font></td> <td> <input type="text" name="sendto_type[]" id="sendto_type1" value="1" >按城市发送 </td> </tr> </table> </form>js代码复制代码 代码如下:<script>function checkForm() { pass = true; $("td:contains('*')").next().find("input").each(function(){ if(this.value == '') { text = $(this).parent().prev().text(); alert(text+"是必填项"); this.focus(); pass = false; return false;//跳出each } }); return pass; } </script>

  推荐阅读

  仿3721首页模块拖曳移动效果js代码[可拖曳层移动层]

仿3721首页模块拖曳移动效果[拖曳层移动层]呵,做了一些细致的处理 html, body { width:100%; height:100%; padding:0px; margin:0px; } body { text-align:center; >>>详细阅读


本文标题:jquery 必填项判断表单是否为空的方法

地址:http://www.17bianji.com/kaifa2/JS/29408.html

关键词: 探索发现

乐购科技部分新闻及文章转载自互联网,供读者交流和学习,若有涉及作者版权等问题请及时与我们联系,以便更正、删除或按规定办理。感谢所有提供资讯的网站,欢迎各类媒体与乐购科技进行文章共享合作。

网友点评
自媒体专栏

评论

热度

精彩导读
栏目ID=71的表不存在(操作类型=0)