欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

jquery 必填項判斷表單是否為空的方法

 更新時間:2008年09月14日 20:42:33   作者:  
jquery 表單驗證,檢測表單是否為空
html頁面
復(fù)制代碼 代碼如下:

<form onsubmit="if(confirm('確定好你所填寫的正確,不然會發(fā)錯!')) {return checkForm();}else{return false;}" >
<table >
<tr>
<td>選擇發(fā)送人<font class="red">*</font></td>
<td>
<input type="text" name="sendto_type[]" id="sendto_type1" value="1" >按城市發(fā)送

</td>
</tr>

<tr>
<td>選擇發(fā)送人2<font class="red">*</font></td>
<td>
<input type="text" name="sendto_type[]" id="sendto_type1" value="1" >按城市發(fā)送
</td>
</tr>
</table>
</form>

js代碼
復(fù)制代碼 代碼如下:

<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>

相關(guān)文章

最新評論