表单验证
jquery方式:
<input type="text" name="student.id" notnull="true" title="编号"> //在不能为空的标签加上notnull="true"
....
<script type="text/javascript"> (function(){ $("").ready(function() { $("#fm1").submit(function(){ var flag=true; $(this).find("[notnull=true]").each(function(){ if(isnull(this)){ flag=false; } }); return flag; }); function isnull(oo){ $(oo).next(".yz_1").remove(); if(oo.value=="") { $(oo).after("<span class='yz_1'> "+oo.title+"不能为空</span>"); // window.alert("blank"); return true; } return false; } }); })(); </script>
效果:


浙公网安备 33010602011771号