自己写的一个类似html5表单属性的表单验证小框架基于jquery
使用实例://绑定邮箱焦点离开事件 $('#password').blur(function(){ validateForm('frm_reg',{loop:false,targetEnumId:$(this).attr('id'),errorElClass:"error-common-input",errorShowClass:"red", showTip:true,tipClass:"tipClass"}); }); //绑定邮箱焦点离开事件 $('#repassword').blur(function(){ validateForm('frm_reg',{loop:false,targetEnumId:$(this).attr('id'),errorElClass:"error-common-input",errorShowClass:"red", showTip:true,tipClass:"tipClass"}); });//表单提交 验证所有元素是否符合要求 $('#btnRegister').click(function(){ //做一些简单规则验证 异步提交由后台判断其他情况 var options ={loop:true,errorElClass:"error-common-input",errorShowClass:"red",showTip:true,tipClass:"tipClass"}; if(validateForm('#frm_reg',options)){ $('#frm_reg').submit(); } });