手机
当前位置:查字典教程网 >编程开发 >Javascript教程 >jquery 必填项判断表单是否为空的方法
jquery 必填项判断表单是否为空的方法
摘要:html页面复制代码代码如下:选择发送人*按城市发送选择发送人2*按城市发送js代码复制代码代码如下:functioncheckForm()...

html页面

复制代码 代码如下:

<form onsubmit="if(confirm('确定好你所填写的正确,不然会发错!')) {return checkForm();}else{return false;}" >

<table >

<tr>

<td>选择发送人<font>*</font></td>

<td>

<input type="text" name="sendto_type[]" id="sendto_type1" value="1" >按城市发送

</td>

</tr>

<tr>

<td>选择发送人2<font>*</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禁止页面刷新与后退的方法

jquery判断至少有一个checkbox被选中的方法

JQuery实现动态添加删除评论的方法

js控制网页前进和后退的方法

jQuery获取页面元素绝对与相对位置的方法

Jquery注册事件实现方法

jQuery实现控制文字内容溢出用省略号(…)表示的方法

jQuery实现仿腾讯微博滑出效果报告每日天气的方法

Jquery解析json字符串及json数组的方法

精品推荐
分类导航