//验证configmodel表单信息
$(function () {
//.onblur?
var checkok = false;
var errmsg1 = "<p id=\"errscode\" style=\"color:red;\">此处不能小于4位!请重新填写。</p>";
$("#scode").blur(function () {
return scodes(errmsg1, "#scode", "#errscode", "#scodeerr");
});
function scodes(errmsgA, slenA, objA, objB) {
var errmsg = errmsgA; //errmsgA
var slen = slenA.val().length;
if (slen < 4) {
$(objA).remove(); //scode
$(objB).append(errmsg); //configsubmit
return checkok = false;
} else {
$(objA).remove();
return checkok = true;
}
}
$("#configsubmit").click(function () {
return scodes(errmsg1, "#scode", "#errscode", "#scodeerr");
if (checkok === true) {
$("#configsubmit").click(function () {
return true;
});
} else {
return false;
}
});
<form id="">
<input id="scode" type="text">
<input type="submit" id="configsubmit" value="ok">
</form>
<div id="scodeerr">?</div>
想让scodes那个函数能用起来,现在看来有问题。谢谢