Commit adc4a768 by Wittaya-PIM

layout : add new 3 .js

parent ac0f9b93
......@@ -94,6 +94,9 @@
<?php echo $this->Html->script('/js/owl.carousel/owl.carousel.min'); ?>
<?php echo $this->Html->script('/js/magnific-popup/jquery.magnific-popup.min'); ?>
<?php echo $this->Html->script('/js/vide/vide.min'); ?>
<?php echo $this->Html->script('/js/validate/jQuery.start.min'); ?>
<?php echo $this->Html->script('/js/validate/jQuery.validate.addValidate'); ?>
<?php echo $this->Html->script('/js/validate/jQuery.validate.min'); ?>
<!-- Theme Base, Components and Settings -->
<?php echo $this->Html->script('theme'); ?>
<!-- Theme Custom -->
......
$(document).ready(function(){$("form").each(function(){$(this).validate()})});
\ No newline at end of file
/**
| ------------------------------------------------------------------------------------------------------------------
| Add for form data validations for another validate in HTML form
| @author Sarawuttb
| @since 2013/05/20 14:37:26
| @license Pakgon Ltd ,Company
| ------------------------------------------------------------------------------------------------------------------
| 1. letters ,Example 'class'="letters"
| 2. capital_letters ,Example 'class'="capital_letter"
| 3. small_letters ,Example 'class'="small_letter"
| 4. length ,Example 'length'=>13
| 5. citizen_no ,Example 'class'=>'citizen_no'
| 6. filesize ,Example 'filesize'=>1024
| 7. extension ,Example 'extension'=>'txt|text|xls'
| 8. accept ,Example 'accept'=>'audio/*,image/*'
| 9. alphanumeric ,Example 'class'=>'alphanumeric'
| 10. lettersonly ,Example 'class'=>'lettersonly'
| 11. integer ,Example 'class'=>'integer'
| 12. time ,Example 'class'=>'time'
| 13. time12 ,Example 'class'=>'time12'
| 14. ipv4 ,Example 'class'=>'ipv4'
| 15. ipv6 ,Example 'class'=>'ipv6'
| 16. ckpassword ,Example 'class'=>'ckpassword'
| 17. chosen ,Example class='chosen'
| 18. ckquarter-max ,Example 'ckquarter-max' = '2'
| 19. ckquarter-min ,Example 'ckquarter-min' = '2'
| ------------------------------------------------------------------------------------------------------------------
*/
jQuery.validator.addMethod("letters", function (value, element) {
return this.optional(element) || /^[a-zA-Z]+$/i.test(value);
}, "เฉพาะตัวอักษรเท่านั้น.");
jQuery.validator.addMethod("capital_letters", function (value, element) {
return this.optional(element) || /^([A-Z])+$/.test(value);
}, "เฉพาะตัวอักษรตัวใหญ่เท่านั้น.");
jQuery.validator.addMethod("small_letters", function (value, element) {
return this.optional(element) || /^([a-z])+$/.test(value);
}, "เฉพาะตัวอักษรตัวเล็กเท่านั้น.");
jQuery.validator.addMethod("length", function (value, element, param) {
return this.optional(element) || (value.length == param);
}, jQuery.validator.format("ความยาวของข้อมูลต้องเท่ากับ {0}"));
jQuery.validator.addMethod("citizen_no", function (value, element) {
var tmp = $.trim(value);
if (tmp == '')
return true;
if (value.length !== 13) {
return false;
}
var IDCard = value,
ValOfPosition = 13,
ValOfPosition13 = null,
ValSum = null,
digit13Check = null;
if (IDCard.length !== 13 || isNaN(IDCard.charAt(IDCard.length - 1))) {
return false;
}
ValOfPosition13 = Number(IDCard.charAt(IDCard.length - 1));
for (var i = 0; i <= IDCard.length - 2; i++) {
if (!isNaN(IDCard.charAt(i))) {
ValSum += Number(IDCard.charAt(i)) * ValOfPosition;
}
ValOfPosition--;
}
digit13Check = Number(11 - (ValSum % 11));
var digit13 = String(digit13Check);
digit13 = digit13.length == 1 ? Number(digit13) : Number(digit13.charAt(1));
return (ValOfPosition13 == digit13);
}, jQuery.validator.format('คุณกรอกหมายเลขบัตรประชาชนไม่ถูกต้อง'));
jQuery.validator.addMethod('filesize', function (value, element, param) {
return this.optional(element) || ((element.files[0].size) <= param)
}, jQuery.validator.format("ขนาดไฟล์ที่ต้องน้อยกว่า หรือเท่ากับ {0} Byte"));
jQuery.validator.addMethod("extension", function (value, element, param) {
param = typeof (param === "string") ? param.replace(/,/g, '|') : "png|jpe?g|gif";
return this.optional(element) || value.match(new RegExp(".(" + param + ")$", "i"));
}, jQuery.format("นามสกุลของไฟล์แนบต้องเป็น {0} เท่านั้น."));
jQuery.validator.addMethod("accept", function (value, element, param) {
var typeParam = typeof (param === "string") ? param.replace(/\s/g, '').replace(/,/g, '|') : "image/*",
optionalValue = this.optional(element),
i,
file;
if (optionalValue) {
return optionalValue;
}
if ($(element).attr("type") === "file") {
typeParam = typeParam.replace(/\*/g, ".*");
if (element.files && element.files.length) {
for (i = 0; i < element.files.length; i++) {
file = element.files[i];
if (!file.type.match(new RegExp(".?(" + typeParam + ")$", "i"))) {
return false;
}
}
}
}
return true;
}, jQuery.format("ประเภทของไฟล์แนบต้องเป็น {0} เท่านั้น"));
jQuery.validator.addMethod("alphanumeric", function (value, element) {
return this.optional(element) || /^\w+$/i.test(value);
}, "ตัวอักษร หรือตัวเลขเท่านั้น");
jQuery.validator.addMethod("lettersonly", function (value, element) {
return this.optional(element) || /^[a-z]+$/i.test(value);
}, "ตัวอักษรเท่านั้น");
jQuery.validator.addMethod("integer", function (value, element) {
return this.optional(element) || /^-?\d+$/.test(value);
}, "จำนวนเต็มบวก หรือจำนวนเต็มลบเท่านั้น");
jQuery.validator.addMethod("time", function (value, element) {
return this.optional(element) || /^([01]\d|2[0-3])(:[0-5]\d){1,2}$/.test(value);
}, "เวลาระหว่าง 00:00 and 23:59 เท่านั้น");
jQuery.validator.addMethod("time12h", function (value, element) {
return this.optional(element) || /^((0?[1-9]|1[012])(:[0-5]\d){1,2}(\ ?[AP]M))$/i.test(value);
}, "เวลาในรูปแบบ 12 ชั่วโมง AM/PM เท่านั้น");
jQuery.validator.addMethod("ipv4", function (value, element, param) {
return this.optional(element) || /^(25[0-5]|2[0-4]\d|[01]?\d\d?)\.(25[0-5]|2[0-4]\d|[01]?\d\d?)\.(25[0-5]|2[0-4]\d|[01]?\d\d?)\.(25[0-5]|2[0-4]\d|[01]?\d\d?)$/i.test(value);
}, " IP v4 เท่านั้น");
jQuery.validator.addMethod("ipv6", function (value, element, param) {
return this.optional(element) || /^((([0-9A-Fa-f]{1,4}:){7}[0-9A-Fa-f]{1,4})|(([0-9A-Fa-f]{1,4}:){6}:[0-9A-Fa-f]{1,4})|(([0-9A-Fa-f]{1,4}:){5}:([0-9A-Fa-f]{1,4}:)?[0-9A-Fa-f]{1,4})|(([0-9A-Fa-f]{1,4}:){4}:([0-9A-Fa-f]{1,4}:){0,2}[0-9A-Fa-f]{1,4})|(([0-9A-Fa-f]{1,4}:){3}:([0-9A-Fa-f]{1,4}:){0,3}[0-9A-Fa-f]{1,4})|(([0-9A-Fa-f]{1,4}:){2}:([0-9A-Fa-f]{1,4}:){0,4}[0-9A-Fa-f]{1,4})|(([0-9A-Fa-f]{1,4}:){6}((\b((25[0-5])|(1\d{2})|(2[0-4]\d)|(\d{1,2}))\b)\.){3}(\b((25[0-5])|(1\d{2})|(2[0-4]\d)|(\d{1,2}))\b))|(([0-9A-Fa-f]{1,4}:){0,5}:((\b((25[0-5])|(1\d{2})|(2[0-4]\d)|(\d{1,2}))\b)\.){3}(\b((25[0-5])|(1\d{2})|(2[0-4]\d)|(\d{1,2}))\b))|(::([0-9A-Fa-f]{1,4}:){0,5}((\b((25[0-5])|(1\d{2})|(2[0-4]\d)|(\d{1,2}))\b)\.){3}(\b((25[0-5])|(1\d{2})|(2[0-4]\d)|(\d{1,2}))\b))|([0-9A-Fa-f]{1,4}::([0-9A-Fa-f]{1,4}:){0,5}[0-9A-Fa-f]{1,4})|(::([0-9A-Fa-f]{1,4}:){0,6}[0-9A-Fa-f]{1,4})|(([0-9A-Fa-f]{1,4}:){1,7}:))$/i.test(value);
}, " IP v6 เท่านั้น");
jQuery.validator.addMethod("chosen", function (value, element) {
return (value == null ? false : (value.length == 0 ? false : true))
}, "please select an option");
jQuery.validator.addMethod("dollarsscents", function (value, element) {
return this.optional(element) || /^-?\d+(\.\d{0,2})?$/i.test(value);
}, "ทศนิยม 2 หลักเท่านั้น");
$.validator.addMethod("ckpassword", function (value, element) {
return (/^[A-Za-z0-9\d=!#$%&\-@._*]*$/.test(value)) && (/[a-z]/.test(value)) && (/[A-Z]/.test(value)) && (/\d/.test(value)) && (value.length >= 8);
}, "รหัสผ่านต้องมีความยาวอย่างน้อย 8 ตัวประกอบด้วย ตัวอักษรเล็ก-ใหญ่ ,ตัวเลขประกอบกัน");
/**
*
* Chosen select validation for required
* @author sarawutt.b
*/
$.validator.addMethod("chosen", function (value, element) {
return (value == null ? false : (value.length == 0 ? false : true))
}, "โปรดเลือกรายการ");
/**
* ตรวจสอบเมื่อมีการเลือกเปลี่ยนไตรมาส ที่สิ้นสุด
* @author sarawutt.b
*/
jQuery.validator.addMethod("ckquarter-max", function (value, element, param) {
return this.optional(element) || (parseInt(value) >= parseInt(param));
}, "ต้องมากกว่าหรือเท่ากับเดือน {0}");
/**
* ตรวจสอบเมื่อมีการเลือกเปลี่ยนไตรมาส ที่สิ้นสุด
* @author sarawutt.b
*/
jQuery.validator.addMethod("ckquarter-min", function (value, element, param) {
return this.optional(element) || (parseInt(value) <= parseInt(param));
}, "ต้องน้อยกว่าหรือเท่ากับเดือน {0}");
\ No newline at end of file
/**
| ------------------------------------------------------------------------------------------------------------------
| Add for form data validations for another validate in HTML form
| @author Sarawuttb
| @since 2013/05/20 14:37:26
| @license Pakgon Ltd ,Company
| ------------------------------------------------------------------------------------------------------------------
| 1. required:true, ,Example 'class'='required'
| 2. rangelength:[2,3], ,Example 'rangelength'="0,10"
| 3. required:true, ,Example 'class'='required'
| 4. maxlength:2, ,Example 'maxlength'='10'
| 5. minlength:2, ,Example 'minlength'='10'
| 6. equalTo: "#password", ,Example 'equalTo'='#password'
| 7. email: true, ,Example 'class'='email'
| 8. url: true, ,Example 'class'='url'
| 9. date: true, ,Example 'class'='date'
| 10. dateISO: true, ,Example 'class'='dateISO'
| 11. number: true, ,Example 'class'='number'
| 12. digits: true, ,Example 'class'='digits'
| 13. creditcard: true, ,Example 'class'='creditcard'
| 14. accept: true, ,Example 'class'='accept'
| 15. rangelength:[?,?] ,Example 'rangelength'='0,10'
| 16. range:[] ,Example 'range'='0,10'
| 17. max:[10] ,Example 'max'='10'
| 18. min:[10] ,Example 'min'='0'
| 19. citizen_no:true ,Example 'class'='citizen_no'
|------------------------------------------------------------------------------------------------------------------------
*/
!function(t){t.extend(t.fn,{validate:function(e){if(!this.length)return void(e&&e.debug&&window.console&&console.warn("Nothing selected, can't validate, returning nothing."));var i=t.data(this[0],"validator");return i?i:(this.attr("novalidate","novalidate"),i=new t.validator(e,this[0]),t.data(this[0],"validator",i),i.settings.onsubmit&&(this.validateDelegate(":submit","click",function(e){i.settings.submitHandler&&(i.submitButton=e.target),t(e.target).hasClass("cancel")&&(i.cancelSubmit=!0)}),this.submit(function(e){function s(){var s;return i.settings.submitHandler?(i.submitButton&&(s=t("<input type='hidden'/>").attr("name",i.submitButton.name).val(i.submitButton.value).appendTo(i.currentForm)),i.settings.submitHandler.call(i,i.currentForm,e),i.submitButton&&s.remove(),!1):!0}return i.settings.debug&&e.preventDefault(),i.cancelSubmit?(i.cancelSubmit=!1,s()):i.form()?i.pendingRequest?(i.formSubmitted=!0,!1):s():(i.focusInvalid(),!1)})),i)},valid:function(){if(t(this[0]).is("form"))return this.validate().form();var e=!0,i=t(this[0].form).validate();return this.each(function(){e&=i.element(this)}),e},removeAttrs:function(e){var i={},s=this;return t.each(e.split(/\s/),function(t,e){i[e]=s.attr(e),s.removeAttr(e)}),i},rules:function(e,i){var s=this[0];if(e){var n=t.data(s.form,"validator").settings,r=n.rules,a=t.validator.staticRules(s);switch(e){case"add":t.extend(a,t.validator.normalizeRule(i)),r[s.name]=a,i.messages&&(n.messages[s.name]=t.extend(n.messages[s.name],i.messages));break;case"remove":if(!i)return delete r[s.name],a;var u={};return t.each(i.split(/\s/),function(t,e){u[e]=a[e],delete a[e]}),u}}var o=t.validator.normalizeRules(t.extend({},t.validator.classRules(s),t.validator.attributeRules(s),t.validator.dataRules(s),t.validator.staticRules(s)),s);if(o.required){var h=o.required;delete o.required,o=t.extend({required:h},o)}return o}}),t.extend(t.expr[":"],{blank:function(e){return!t.trim(""+e.value)},filled:function(e){return!!t.trim(""+e.value)},unchecked:function(t){return!t.checked}}),t.validator=function(e,i){this.settings=t.extend(!0,{},t.validator.defaults,e),this.currentForm=i,this.init()},t.validator.format=function(e,i){return 1===arguments.length?function(){var i=t.makeArray(arguments);return i.unshift(e),t.validator.format.apply(this,i)}:(arguments.length>2&&i.constructor!==Array&&(i=t.makeArray(arguments).slice(1)),i.constructor!==Array&&(i=[i]),t.each(i,function(t,i){e=e.replace(new RegExp("\\{"+t+"\\}","g"),function(){return i})}),e)},t.extend(t.validator,{defaults:{messages:{},groups:{},rules:{},errorClass:"ui-pakgon-text-error",validClass:"valid",errorElement:"ui-pakgon-input-error",focusInvalid:!0,errorContainer:t([]),errorLabelContainer:t([]),onsubmit:!0,ignore:":hidden",ignoreTitle:!1,onfocusin:function(t,e){this.lastActive=t,this.settings.focusCleanup&&!this.blockFocusCleanup&&(this.settings.unhighlight&&this.settings.unhighlight.call(this,t,this.settings.errorClass,this.settings.validClass),this.addWrapper(this.errorsFor(t)).hide())},onfocusout:function(t,e){this.checkable(t)||!(t.name in this.submitted)&&this.optional(t)||this.element(t)},onkeyup:function(t,e){(9!==e.which||""!==this.elementValue(t))&&(t.name in this.submitted||t===this.lastElement)&&this.element(t)},onclick:function(t,e){t.name in this.submitted?this.element(t):t.parentNode.name in this.submitted&&this.element(t.parentNode)},highlight:function(e,i,s){"radio"===e.type?this.findByName(e.name).addClass(i).removeClass(s):t(e).addClass(i).removeClass(s)},unhighlight:function(e,i,s){"radio"===e.type?this.findByName(e.name).removeClass(i).addClass(s):t(e).removeClass(i).addClass(s)}},setDefaults:function(e){t.extend(t.validator.defaults,e)},messages:{required:"โปรดระบุ",remote:"โปรดแก้ไขให้ถูกต้อง",email:"โปรดระบุที่อยู่อีเมล์ที่ถูกต้อง",url:"โปรดระบุ URL ที่ถูกต้อง",date:"โปรดระบุวันที่ ที่ถูกต้อง",dateISO:"โปรดระบุวันที่ ที่ถูกต้อง (ระบบ ISO).",number:"โปรดระบุทศนิยมที่ถูกต้อง",digits:"โปรดระบุจำนวนเต็มที่ถูกต้อง",creditcard:"โปรดระบุรหัสบัตรเครดิตที่ถูกต้อง",equalTo:"โปรดระบุค่าเดิมอีกครั้ง",accept:"โปรดระบุค่าที่มีส่วนขยายที่ถูกต้อง",maxlength:t.validator.format("โปรดอย่าระบุค่าที่ยาวกว่า {0} อักขระ"),minlength:t.validator.format("โปรดอย่าระบุค่าที่สั้นกว่า {0} อักขระ"),rangelength:t.validator.format("โปรดระบุค่าความยาวระหว่าง {0} ถึง {1} อักขระ"),range:t.validator.format("โปรดระบุค่าระหว่าง {0} และ {1}"),max:t.validator.format("โปรดระบุค่าน้อยกว่าหรือเท่ากับ {0}"),min:t.validator.format("โปรดระบุค่ามากกว่าหรือเท่ากับ {0}")},autoCreateRanges:!1,prototype:{init:function(){function e(e){var i=t.data(this[0].form,"validator"),s="on"+e.type.replace(/^validate/,"");i.settings[s]&&i.settings[s].call(i,this[0],e)}this.labelContainer=t(this.settings.errorLabelContainer),this.errorContext=this.labelContainer.length&&this.labelContainer||t(this.currentForm),this.containers=t(this.settings.errorContainer).add(this.settings.errorLabelContainer),this.submitted={},this.valueCache={},this.pendingRequest=0,this.pending={},this.invalid={},this.reset();var i=this.groups={};t.each(this.settings.groups,function(e,s){"string"==typeof s&&(s=s.split(/\s/)),t.each(s,function(t,s){i[s]=e})});var s=this.settings.rules;t.each(s,function(e,i){s[e]=t.validator.normalizeRule(i)}),t(this.currentForm).validateDelegate(":text, [type='password'], [type='file'], select, textarea, [type='number'], [type='search'] ,[type='tel'], [type='url'], [type='email'], [type='datetime'], [type='date'], [type='month'], [type='week'], [type='time'], [type='datetime-local'], [type='range'], [type='color'] ","focusin focusout keyup",e).validateDelegate("[type='radio'], [type='checkbox'], select, option","click",e),this.settings.invalidHandler&&t(this.currentForm).bind("invalid-form.validate",this.settings.invalidHandler)},form:function(){return this.checkForm(),t.extend(this.submitted,this.errorMap),this.invalid=t.extend({},this.errorMap),this.valid()||t(this.currentForm).triggerHandler("invalid-form",[this]),this.showErrors(),this.valid()},checkForm:function(){this.prepareForm();for(var t=0,e=this.currentElements=this.elements();e[t];t++)this.check(e[t]);return this.valid()},element:function(e){e=this.validationTargetFor(this.clean(e)),this.lastElement=e,this.prepareElement(e),this.currentElements=t(e);var i=this.check(e)!==!1;return i?delete this.invalid[e.name]:this.invalid[e.name]=!0,this.numberOfInvalids()||(this.toHide=this.toHide.add(this.containers)),this.showErrors(),i},showErrors:function(e){if(e){t.extend(this.errorMap,e),this.errorList=[];for(var i in e)this.errorList.push({message:e[i],element:this.findByName(i)[0]});this.successList=t.grep(this.successList,function(t){return!(t.name in e)})}this.settings.showErrors?this.settings.showErrors.call(this,this.errorMap,this.errorList):this.defaultShowErrors()},resetForm:function(){t.fn.resetForm&&t(this.currentForm).resetForm(),this.submitted={},this.lastElement=null,this.prepareForm(),this.hideErrors(),this.elements().removeClass(this.settings.errorClass).removeData("previousValue")},numberOfInvalids:function(){return this.objectLength(this.invalid)},objectLength:function(t){var e=0;for(var i in t)e++;return e},hideErrors:function(){this.addWrapper(this.toHide).hide()},valid:function(){return 0===this.size()},size:function(){return this.errorList.length},focusInvalid:function(){if(this.settings.focusInvalid)try{t(this.findLastActive()||this.errorList.length&&this.errorList[0].element||[]).filter(":visible").focus().trigger("focusin")}catch(e){}},findLastActive:function(){var e=this.lastActive;return e&&1===t.grep(this.errorList,function(t){return t.element.name===e.name}).length&&e},elements:function(){var e=this,i={};return t(this.currentForm).find("input, select, textarea").not(":submit, :reset, :image, [disabled]").not(this.settings.ignore).filter(function(){if(!this.name)throw window.console&&console.error("%o has no name assigned",this),new Error("Failed to validate, found an element with no name assigned. See console for element reference.");return this.name in i||!e.objectLength(t(this).rules())?!1:(i[this.name]=!0,!0)})},clean:function(e){return t(e)[0]},errors:function(){var e=this.settings.errorClass.replace(" ",".");return t(this.settings.errorElement+"."+e,this.errorContext)},reset:function(){this.successList=[],this.errorList=[],this.errorMap={},this.toShow=t([]),this.toHide=t([]),this.currentElements=t([])},prepareForm:function(){this.reset(),this.toHide=this.errors().add(this.containers)},prepareElement:function(t){this.reset(),this.toHide=this.errorsFor(t)},elementValue:function(e){var i=t(e).attr("type"),s=t(e).val();return"radio"===i||"checkbox"===i?t("input[name='"+t(e).attr("name")+"']:checked").val():"string"==typeof s?s.replace(/\r/g,""):s},check:function(e){e=this.validationTargetFor(this.clean(e));var i,s=t(e).rules(),n=!1,r=this.elementValue(e);for(var a in s){var u={method:a,parameters:s[a]};try{if(i=t.validator.methods[a].call(this,r,e,u.parameters),"dependency-mismatch"===i){n=!0;continue}if(n=!1,"pending"===i)return void(this.toHide=this.toHide.not(this.errorsFor(e)));if(!i)return this.formatAndAdd(e,u),!1}catch(o){throw this.settings.debug&&window.console&&console.log("Exception occured when checking element "+e.id+", check the '"+u.method+"' method.",o),o}}return n?void 0:(this.objectLength(s)&&this.successList.push(e),!0)},customDataMessage:function(e,i){return t(e).data("msg-"+i.toLowerCase())||e.attributes&&t(e).attr("data-msg-"+i.toLowerCase())},customMessage:function(t,e){var i=this.settings.messages[t];return i&&(i.constructor===String?i:i[e])},findDefined:function(){for(var t=0;t<arguments.length;t++)if(void 0!==arguments[t])return arguments[t]},defaultMessage:function(e,i){return this.findDefined(this.customMessage(e.name,i),this.customDataMessage(e,i),!this.settings.ignoreTitle&&e.title||void 0,t.validator.messages[i],"<strong>Warning: No message defined for "+e.name+"</strong>")},formatAndAdd:function(e,i){var s=this.defaultMessage(e,i.method),n=/\$?\{(\d+)\}/g;"function"==typeof s?s=s.call(this,i.parameters,e):n.test(s)&&(s=t.validator.format(s.replace(n,"{$1}"),i.parameters)),this.errorList.push({message:s,element:e}),this.errorMap[e.name]=s,this.submitted[e.name]=s},addWrapper:function(t){return this.settings.wrapper&&(t=t.add(t.parent(this.settings.wrapper))),t},defaultShowErrors:function(){var t,e;for(t=0;this.errorList[t];t++){var i=this.errorList[t];this.settings.highlight&&this.settings.highlight.call(this,i.element,this.settings.errorClass,this.settings.validClass),this.showLabel(i.element,i.message)}if(this.errorList.length&&(this.toShow=this.toShow.add(this.containers)),this.settings.success)for(t=0;this.successList[t];t++)this.showLabel(this.successList[t]);if(this.settings.unhighlight)for(t=0,e=this.validElements();e[t];t++)this.settings.unhighlight.call(this,e[t],this.settings.errorClass,this.settings.validClass);this.toHide=this.toHide.not(this.toShow),this.hideErrors(),this.addWrapper(this.toShow).show()},validElements:function(){return this.currentElements.not(this.invalidElements())},invalidElements:function(){return t(this.errorList).map(function(){return this.element})},showLabel:function(e,i){var s=this.errorsFor(e);s.length?(s.removeClass(this.settings.validClass).addClass(this.settings.errorClass),s.attr("generated")&&s.html(i)):(s=t("<"+this.settings.errorElement+"/>").attr({"for":this.idOrName(e),generated:!0}).addClass(this.settings.errorClass).html(i||""),this.settings.wrapper&&(s=s.hide().show().wrap("<"+this.settings.wrapper+"/>").parent()),this.labelContainer.append(s).length||(this.settings.errorPlacement?this.settings.errorPlacement(s,t(e)):s.insertAfter(e))),!i&&this.settings.success&&(s.text(""),"string"==typeof this.settings.success?s.addClass(this.settings.success):this.settings.success(s,e)),this.toShow=this.toShow.add(s)},errorsFor:function(e){var i=this.idOrName(e);return this.errors().filter(function(){return t(this).attr("for")===i})},idOrName:function(t){return this.groups[t.name]||(this.checkable(t)?t.name:t.id||t.name)},validationTargetFor:function(t){return this.checkable(t)&&(t=this.findByName(t.name).not(this.settings.ignore)[0]),t},checkable:function(t){return/radio|checkbox/i.test(t.type)},findByName:function(e){return t(this.currentForm).find("[name='"+e+"']")},getLength:function(e,i){switch(i.nodeName.toLowerCase()){case"select":return t("option:selected",i).length;case"input":if(this.checkable(i))return this.findByName(i.name).filter(":checked").length}return e.length},depend:function(t,e){return this.dependTypes[typeof t]?this.dependTypes[typeof t](t,e):!0},dependTypes:{"boolean":function(t,e){return t},string:function(e,i){return!!t(e,i.form).length},"function":function(t,e){return t(e)}},optional:function(e){var i=this.elementValue(e);return!t.validator.methods.required.call(this,i,e)&&"dependency-mismatch"},startRequest:function(t){this.pending[t.name]||(this.pendingRequest++,this.pending[t.name]=!0)},stopRequest:function(e,i){this.pendingRequest--,this.pendingRequest<0&&(this.pendingRequest=0),delete this.pending[e.name],i&&0===this.pendingRequest&&this.formSubmitted&&this.form()?(t(this.currentForm).submit(),this.formSubmitted=!1):!i&&0===this.pendingRequest&&this.formSubmitted&&(t(this.currentForm).triggerHandler("invalid-form",[this]),this.formSubmitted=!1)},previousValue:function(e){return t.data(e,"previousValue")||t.data(e,"previousValue",{old:null,valid:!0,message:this.defaultMessage(e,"remote")})}},classRuleSettings:{required:{required:!0},email:{email:!0},url:{url:!0},date:{date:!0},dateISO:{dateISO:!0},number:{number:!0},digits:{digits:!0},creditcard:{creditcard:!0}},addClassRules:function(e,i){e.constructor===String?this.classRuleSettings[e]=i:t.extend(this.classRuleSettings,e)},classRules:function(e){var i={},s=t(e).attr("class");return s&&t.each(s.split(" "),function(){this in t.validator.classRuleSettings&&t.extend(i,t.validator.classRuleSettings[this])}),i},attributeRules:function(e){var i={},s=t(e);for(var n in t.validator.methods){var r;"required"===n?(r=s.get(0).getAttribute(n),""===r&&(r=!0),r=!!r):r=s.attr(n),r?i[n]=r:s[0].getAttribute("type")===n&&(i[n]=!0)}return i.maxlength&&/-1|2147483647|524288/.test(i.maxlength)&&delete i.maxlength,i},dataRules:function(e){var i,s,n={},r=t(e);for(i in t.validator.methods)s=r.data("rule-"+i.toLowerCase()),void 0!==s&&(n[i]=s);return n},staticRules:function(e){var i={},s=t.data(e.form,"validator");return s.settings.rules&&(i=t.validator.normalizeRule(s.settings.rules[e.name])||{}),i},normalizeRules:function(e,i){return t.each(e,function(s,n){if(n===!1)return void delete e[s];if(n.param||n.depends){var r=!0;switch(typeof n.depends){case"string":r=!!t(n.depends,i.form).length;break;case"function":r=n.depends.call(i,i)}r?e[s]=void 0!==n.param?n.param:!0:delete e[s]}}),t.each(e,function(s,n){e[s]=t.isFunction(n)?n(i):n}),t.each(["minlength","maxlength","min","max"],function(){e[this]&&(e[this]=Number(e[this]))}),t.each(["rangelength","range"],function(){var i;e[this]&&(t.isArray(e[this])?e[this]=[Number(e[this][0]),Number(e[this][1])]:"string"==typeof e[this]&&(i=e[this].split(/[\s,]+/),e[this]=[Number(i[0]),Number(i[1])]))}),t.validator.autoCreateRanges&&(e.min&&e.max&&(e.range=[e.min,e.max],delete e.min,delete e.max),e.minlength&&e.maxlength&&(e.rangelength=[e.minlength,e.maxlength],delete e.minlength,delete e.maxlength)),e},normalizeRule:function(e){if("string"==typeof e){var i={};t.each(e.split(/\s/),function(){i[this]=!0}),e=i}return e},addMethod:function(e,i,s){t.validator.methods[e]=i,t.validator.messages[e]=void 0!==s?s:t.validator.messages[e],i.length<3&&t.validator.addClassRules(e,t.validator.normalizeRule(e))},methods:{required:function(e,i,s){if(!this.depend(s,i))return"dependency-mismatch";if("select"===i.nodeName.toLowerCase()){var n=t(i).val();return n&&n.length>0}return this.checkable(i)?this.getLength(e,i)>0:t.trim(e).length>0},remote:function(e,i,s){if(this.optional(i))return"dependency-mismatch";var n=this.previousValue(i);if(this.settings.messages[i.name]||(this.settings.messages[i.name]={}),n.originalMessage=this.settings.messages[i.name].remote,this.settings.messages[i.name].remote=n.message,s="string"==typeof s&&{url:s}||s,n.old===e)return n.valid;n.old=e;var r=this;this.startRequest(i);var a={};return a[i.name]=e,t.ajax(t.extend(!0,{url:s,mode:"abort",port:"validate"+i.name,dataType:"json",data:a,success:function(s){r.settings.messages[i.name].remote=n.originalMessage;var a=s===!0||"true"===s;if(a){var u=r.formSubmitted;r.prepareElement(i),r.formSubmitted=u,r.successList.push(i),delete r.invalid[i.name],r.showErrors()}else{var o={},h=s||r.defaultMessage(i,"remote");o[i.name]=n.message=t.isFunction(h)?h(e):h,r.invalid[i.name]=!0,r.showErrors(o)}n.valid=a,r.stopRequest(i,a)}},s)),"pending"},minlength:function(e,i,s){var n=t.isArray(e)?e.length:this.getLength(t.trim(e),i);return this.optional(i)||n>=s},maxlength:function(e,i,s){var n=t.isArray(e)?e.length:this.getLength(t.trim(e),i);return this.optional(i)||s>=n},rangelength:function(e,i,s){var n=t.isArray(e)?e.length:this.getLength(t.trim(e),i);return this.optional(i)||n>=s[0]&&n<=s[1]},min:function(t,e,i){return this.optional(e)||t>=i},max:function(t,e,i){return this.optional(e)||i>=t},range:function(t,e,i){return this.optional(e)||t>=i[0]&&t<=i[1]},email:function(t,e){return this.optional(e)||/^((([a-z]|\d|[!#\$%&'\*\+\-\/=\?\^_`{\|}~]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+(\.([a-z]|\d|[!#\$%&'\*\+\-\/=\?\^_`{\|}~]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+)*)|((\x22)((((\x20|\x09)*(\x0d\x0a))?(\x20|\x09)+)?(([\x01-\x08\x0b\x0c\x0e-\x1f\x7f]|\x21|[\x23-\x5b]|[\x5d-\x7e]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(\\([\x01-\x09\x0b\x0c\x0d-\x7f]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]))))*(((\x20|\x09)*(\x0d\x0a))?(\x20|\x09)+)?(\x22)))@((([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.)+(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))$/i.test(t)},url:function(t,e){return this.optional(e)||/^(https?|s?ftp):\/\/(((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:)*@)?(((\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])\.(\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])\.(\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])\.(\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5]))|((([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.)+(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.?)(:\d*)?)(\/((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)+(\/(([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)*)*)?)?(\?((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)|[\uE000-\uF8FF]|\/|\?)*)?(#((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)|\/|\?)*)?$/i.test(t)},date:function(t,e){return this.optional(e)||!/Invalid|NaN/.test(new Date(t).toString())},dateISO:function(t,e){return this.optional(e)||/^\d{4}[\/\-]\d{1,2}[\/\-]\d{1,2}$/.test(t)},number:function(t,e){return this.optional(e)||/^-?(?:\d+|\d{1,3}(?:,\d{3})+)?(?:\.\d+)?$/.test(t)},digits:function(t,e){return this.optional(e)||/^\d+$/.test(t)},creditcard:function(t,e){if(this.optional(e))return"dependency-mismatch";if(/[^0-9 \-]+/.test(t))return!1;var i=0,s=0,n=!1;t=t.replace(/\D/g,"");for(var r=t.length-1;r>=0;r--){var a=t.charAt(r);s=parseInt(a,10),n&&(s*=2)>9&&(s-=9),i+=s,n=!n}return i%10===0},equalTo:function(e,i,s){var n=t(s);return this.settings.onfocusout&&n.unbind(".validate-equalTo").bind("blur.validate-equalTo",function(){t(i).valid()}),e===n.val()}}}),t.format=t.validator.format}(jQuery),function(t){var e={};if(t.ajaxPrefilter)t.ajaxPrefilter(function(t,i,s){var n=t.port;"abort"===t.mode&&(e[n]&&e[n].abort(),e[n]=s)});else{var i=t.ajax;t.ajax=function(s){var n=("mode"in s?s:t.ajaxSettings).mode,r=("port"in s?s:t.ajaxSettings).port;return"abort"===n?(e[r]&&e[r].abort(),e[r]=i.apply(this,arguments)):i.apply(this,arguments)}}}(jQuery),function(t){t.extend(t.fn,{validateDelegate:function(e,i,s){return this.bind(i,function(i){var n=t(i.target);return n.is(e)?s.apply(n,arguments):void 0})}})}(jQuery);
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment