//juqery 判断所有input 不能为空var $kong = $(".kong"); $kong.each(function(i){ if($(this).val() == ""){ layer.open({ content: "aaa" //判断哪个值没填写 ,skin: ‘msg‘ ,time: 3 //3秒后自动关闭 }); return false; } });
//判断手机号正确格式 if(!(/^1[3-8]{1}\d{9}$/.test(tel))){ layer.open({ content: "请输入正确格式的手机号" //判断哪个值没填写 ,skin: ‘msg‘ ,time: 3 //3秒后自动关闭 }); return false; }
html<span><input type="text" placeholder="缴费金额..." name="pay[]" value="" class="name kong score"></span> juqery var isNum = true; $(function(){ $(‘input.score‘).change(function(){ checkScore(); }); }) var checkScore = function(){ $.each($(‘input.score‘),function(index,ele){ var curVal = $(ele).val(); if(isNaN(curVal)){ isNum = false; return false; }else{ isNum = true; } }) //console.log(isNum); } if(!isNum){ layer.open({ content: ‘缴费金额只能是数字!‘ //判断哪个值没填写 ,skin: ‘msg‘ ,time: 1 //3秒后自动关闭 }); }
时间: 2024-11-08 13:13:56