$(function(){ $("#loanForm").validate({ rules:{ name:{ required:true, maxlength:24, }, interfaceLink:{ required:true, myUrl:true, maxlength:255, }, packageName:{ required:true, maxlength:255, }, }, errorPlacement: function (error, element) { //指定错误信息位置 if (element.is(':radio')) { //如果是radio var eid = element.attr('name'); //获取元素的name属性 error.appendTo(element.parent().parent()); //将错误信息添加当前元素的父结点后面 } else { error.insertAfter(element); } } , onkeyup:false, focusCleanup:true, success:"valid", submitHandler:function(form) { var flagChecks = $("input[id^=flag]:checked"); $.each(flagChecks,function(idx,flag){ $("input:hidden[name="+ flag.name+ "]").remove(); }); var typeChecks = $("input[id$=Flag]:checked"); $.each(typeChecks,function(idx,flag){ $("input:hidden[name="+ flag.name+ "]").remove(); }); $(form).ajaxSubmit({ type: 'post', enctype:"multipart/form-data", url: '${consoleUrl}/loan/loan/saveOrUpdate.do', data: $(form).serialize(), success: function (data) { if (data.flag) { layer.msg(data.msg, {icon: 1, time: 1000}, function () { parent.location.href = '${consoleUrl}/loan/loan/index.do'; }); } else { layer.msg(data.msg, {icon: 2, time: 1000}); } } }); return false; } }); });
单选框的表单提交的验证
最新推荐文章于 2023-09-22 10:00:53 发布