jquery 必填项判断表单是否为空的方法
2008-09-14 00:00
447 查看
html页面
js代码
<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>
相关文章推荐
- jquery 必填项判断表单是否为空的方法
- jquery 必填项判断表单是否为空的方法
- js replace 全局替换 以表单的方式提交参数 判断是否为ie浏览器 将jquery.qqFace.js表情转换成微信的字符码 手机端省市区联动 新字体引用本地运行可以获得,放到服务器上报404 C#提取html中的汉字 MVC几种找不到资源的解决方式 使用Windows服务定时去执行一个方法的三种方式
- jQuery判断checkbox是否选中的3种方法
- jQuery判断checkbox是否选中的3种方法
- jQuery判断checkbox是否选中的3种方法
- jQuery 判断图片是否加载完成方法汇总
- jQuery判断checkbox是否选中的3种方法
- jQuery判断checkbox是否选中的方法和动态选择和反选
- jquery判断表单是否被选中的小例子
- jQuery:提交表单前判断表单是否被修改过
- jQuery判断指定id的对象是否存在的方法
- 判断一个对象是否为jquery对象的方法
- jquery判断字符串中是否包含特定字符的方法总结
- jQuery判断checkbox是否选中的3种方法
- JavaScript判断用户是否对表单进行了修改的方法
- jquery判断单选按钮radio是否选中的方法
- PHP判断FORM表单或URL参数来的数据是否为整数的方法
- PHP判断FORM表单或URL参数来的数据是否为整数的方法