|
復(fù)制代碼 代碼如下:
<form onsubmit="if(confirm('確定好你所填寫的正確,不然會發(fā)錯(cuò)!')) {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+"是必填項(xiàng)");
this.focus();
pass = false;
return false;//跳出each
}
});
return pass;
}
</script>
JavaScript技術(shù):jquery 必填項(xiàng)判斷表單是否為空的方法,轉(zhuǎn)載需保留來源!
鄭重聲明:本文版權(quán)歸原作者所有,轉(zhuǎn)載文章僅為傳播更多信息之目的,如作者信息標(biāo)記有誤,請第一時(shí)間聯(lián)系我們修改或刪除,多謝。