ajaxComplete: function(ajaxReturn, pass) { var $shbh = $('#fmerchantId'); var accountInfo = $shbh.parent().find('.error-info.account'); var emptyInfo = $shbh.parent().find('.error-info.empty'); if ($shbh.val() == '') { if (!emptyInfo.size()) { $shbh.parent().append('<div class="error-info empty">' + $shbh.data('emptyinfo') + '</div>'); } else { emptyInfo.show(); } } else { emptyInfo.hide(); if (!accountCheck.isPass()) { $shbh.parents('.form-group:first').addClass('has-error'); if (!accountInfo.size()) { $shbh.parent().append('<div class="error-info account">该账号不存在,请重新输入!</div>'); } else { accountInfo.show(); } } else { accountInfo.hide(); } } }
/** * [validate 检验函数] * @param {[HTML Element]} el [要校验的元素,不传递则全部检查] * @return {[Boolean]} [description] */ function validate(el) { var pass = true; if (el) { var elp = el.parents('.form-group:first'); if (el.data('date-format')) { if (Utils.isDate(el.val())) { elp.removeClass('has-error'); } else { pass = false; elp.addClass('has-error'); } } else if (el.data('int')) { if ($.isNumeric(el.val())) { elp.removeClass('has-error'); } else { pass = false; elp.addClass('has-error'); } } } else { $('.bootbox input').each(function(i, v) { var $el = $(this), $p = $el.parents('.form-group:first'), isInt = $el.data('int'), isEmpty = $el.data('empty'), isDate = $el.hasClass('datepicker'); if (isDate) { if (Utils.isDate($el.val())) { $p.removeClass('has-error'); } else { pass = false; $p.addClass('has-error'); } } if (isInt) { if ($.isNumeric($el.val())) { $p.removeClass('has-error'); } else { pass = false; $p.addClass('has-error'); } } if (isEmpty) { if ('' != $el.val().trim()) { $p.removeClass('has-error'); } else { pass = false; $p.addClass('has-error'); } } // if ('fexpirationDate' == $el.attr('id')) { // val = $el.val(); // errorInfo = $p.find('.error-info'); // if (val) { // try { // if (new Date(val).getTime() < new Date(Utils.date.getTodayStr() + ' 00:00:00').getTime()) { // if (errorInfo.size()) { // errorInfo.html('请选择正确的日期。'); // } else { // $el.parent().parent().append('<div class="error-info len">请选择正确的日期。</div>'); // } // $p.addClass('has-error'); // pass = false; // } else { // errorInfo.hide(); // $p.removeClass('has-error'); // } // } catch (e) { // pass = false; // } // } // } }); }!accountCheck.isPass() && $('#fmerchantId').parents('.form-group:first').addClass('has-error'); return accountCheck.isPass() && pass; }