jquery必填项判断表单是否为空的方法_jquery
来源:动视网
责编:小采
时间:2020-11-27 20:39:58
jquery必填项判断表单是否为空的方法_jquery
jquery必填项判断表单是否为空的方法_jquery:html页面 代码如下:js代码 代码如下:function checkForm() { pass = true; $(td:contains('*')).next().find(input).each(function(){ if(this.value == '') { text = $(this).parent().prev().te
导读jquery必填项判断表单是否为空的方法_jquery:html页面 代码如下:js代码 代码如下:function checkForm() { pass = true; $(td:contains('*')).next().find(input).each(function(){ if(this.value == '') { text = $(this).parent().prev().te

html页面
代码如下:
js代码
代码如下:
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
jquery必填项判断表单是否为空的方法_jquery:html页面 代码如下:js代码 代码如下:function checkForm() { pass = true; $(td:contains('*')).next().find(input).each(function(){ if(this.value == '') { text = $(this).parent().prev().te