1/* 2 * jQuery validation plug-in 1.7 3 * 4 * http://bassistance.de/jquery-plugins/jquery-plugin-validation/ 5 * http://docs.jquery.com/Plugins/Validation 6 * 7 * Copyright (c) 2006 - 2008 Jörn Zaefferer 8 * 9 * $Id: jquery.validate.js 6403 2009-06-17 14:27:16Z joern.zaefferer $ 10 * 11 * Dual licensed under the MIT and GPL licenses: 12 * http://www.opensource.org/licenses/mit-license.php 13 * http://www.gnu.org/licenses/gpl.html 14 */ 15(function ($) { 16 $.extend($.fn, {validate:function (options) { 17 if (!this.length) { 18 options && options.debug && window.console && console.warn("nothing selected, can't validate, returning nothing"); 19 return; 20 } 21 var validator = $.data(this[0], 'validator'); 22 if (validator) { 23 return validator; 24 } 25 validator = new $.validator(options, this[0]); 26 $.data(this[0], 'validator', validator); 27 if (validator.settings.onsubmit) { 28 this.find("input, button").filter(".cancel").click(function () { 29 validator.cancelSubmit = true; 30 }); 31 if (validator.settings.submitHandler) { 32 this.find("input, button").filter(":submit").click(function () { 33 validator.submitButton = this; 34 }); 35 } 36 this.submit(function (event) { 37 if (validator.settings.debug)event.preventDefault(); 38 function handle() { 39 if (validator.settings.submitHandler) { 40 if (validator.submitButton) { 41 var hidden = $("<input type='hidden'/>").attr("name", validator.submitButton.name).val(validator.submitButton.value).appendTo(validator.currentForm); 42 } 43 validator.settings.submitHandler.call(validator, validator.currentForm); 44 if (validator.submitButton) { 45 hidden.remove(); 46 } 47 return false; 48 } 49 return true; 50 } 51 52 if (validator.cancelSubmit) { 53 validator.cancelSubmit = false; 54 return handle(); 55 } 56 if (validator.form()) { 57 if (validator.pendingRequest) { 58 validator.formSubmitted = true; 59 return false; 60 } 61 return handle(); 62 } else { 63 validator.focusInvalid(); 64 return false; 65 } 66 }); 67 } 68 return validator; 69 }, valid:function () { 70 if ($(this[0]).is('form')) { 71 return this.validate().form(); 72 } else { 73 var valid = true; 74 var validator = $(this[0].form).validate(); 75 this.each(function () { 76 valid &= validator.element(this); 77 }); 78 return valid; 79 } 80 }, removeAttrs:function (attributes) { 81 var result = {}, $element = this; 82 $.each(attributes.split(/\s/), function (index, value) { 83 result[value] = $element.attr(value); 84 $element.removeAttr(value); 85 }); 86 return result; 87 }, rules:function (command, argument) { 88 var element = this[0]; 89 if (command) { 90 var settings = $.data(element.form, 'validator').settings; 91 var staticRules = settings.rules; 92 var existingRules = $.validator.staticRules(element); 93 switch (command) { 94 case"add": 95 $.extend(existingRules, $.validator.normalizeRule(argument)); 96 staticRules[element.name] = existingRules; 97 if (argument.messages)settings.messages[element.name] = $.extend(settings.messages[element.name], argument.messages); 98 break; 99 case"remove": 100 if (!argument) { 101 delete staticRules[element.name]; 102 return existingRules; 103 } 104 var filtered = {}; 105 $.each(argument.split(/\s/), function (index, method) { 106 filtered[method] = existingRules[method]; 107 delete existingRules[method]; 108 }); 109 return filtered; 110 } 111 } 112 var data = $.validator.normalizeRules($.extend({}, $.validator.metadataRules(element), $.validator.classRules(element), $.validator.attributeRules(element), $.validator.staticRules(element)), element); 113 if (data.required) { 114 var param = data.required; 115 delete data.required; 116 data = $.extend({required:param}, data); 117 } 118 return data; 119 }}); 120 $.extend($.expr[":"], {blank:function (a) { 121 return!$.trim("" + a.value); 122 }, filled:function (a) { 123 return!!$.trim("" + a.value); 124 }, unchecked:function (a) { 125 return!a.checked; 126 }}); 127 $.validator = function (options, form) { 128 this.settings = $.extend(true, {}, $.validator.defaults, options); 129 this.currentForm = form; 130 this.init(); 131 }; 132 $.validator.format = function (source, params) { 133 if (arguments.length == 1)return function () { 134 var args = $.makeArray(arguments); 135 args.unshift(source); 136 return $.validator.format.apply(this, args); 137 }; 138 if (arguments.length > 2 && params.constructor != Array) { 139 params = $.makeArray(arguments).slice(1); 140 } 141 if (params.constructor != Array) { 142 params = [params]; 143 } 144 $.each(params, function (i, n) { 145 source = source.replace(new RegExp("\\{" + i + "\\}", "g"), n); 146 }); 147 return source; 148 }; 149 $.extend($.validator, {defaults:{messages:{}, groups:{}, rules:{}, errorClass:"error", validClass:"valid", errorElement:"label", focusInvalid:true, errorContainer:$([]), errorLabelContainer:$([]), onsubmit:true, ignore:[], ignoreTitle:false, onfocusin:function (element) { 150 this.lastActive = element; 151 if (this.settings.focusCleanup && !this.blockFocusCleanup) { 152 this.settings.unhighlight && this.settings.unhighlight.call(this, element, this.settings.errorClass, this.settings.val
152idClass); 153 this.errorsFor(element).hide(); 154 } 155 }, onfocusout:function (element) { 156 if (!this.checkable(element) && (element.name in this.submitted || !this.optional(element))) { 157 this.element(element); 158 } 159 }, onkeyup:function (element) { 160 if (element.name in this.submitted || element == this.lastElement) { 161 this.element(element); 162 } 163 }, onclick:function (element) { 164 if (element.name in this.submitted)this.element(element); else if (element.parentNode.name in this.submitted)this.element(element.parentNode); 165 }, highlight:function (element, errorClass, validClass) { 166 $(element).addClass(errorClass).removeClass(validClass); 167 }, unhighlight:function (element, errorClass, validClass) { 168 $(element).removeClass(errorClass).addClass(validClass); 169 }}, setDefaults:function (settings) { 170 $.extend($.validator.defaults, settings); 171 }, messages:{required:"This field is required.", remote:"Please fix this field.", email:"Please enter a valid email address.", url:"Please enter a valid URL.", date:"Please enter a valid date.", dateISO:"Please enter a valid date (ISO).", number:"Please enter a valid number.", digits:"Please enter only digits.", creditcard:"Please enter a valid credit card number.", equalTo:"Please enter the same value again.", accept:"Please enter a value with a valid extension.", maxlength:$.validator.format("Please enter no more than {0} characters."), minlength:$.validator.format("Please enter at least {0} characters."), rangelength:$.validator.format("Please enter a value between {0} and {1} characters long."), range:$.validator.format("Please enter a value between {0} and {1}."), max:$.validator.format("Please enter a value less than or equal to {0}."), min:$.validator.format("Please enter a value greater than or equal to {0}.")}, autoCreateRanges:false, prototype:{init:function () { 172 this.labelContainer = $(this.settings.errorLabelContainer); 173 this.errorContext = this.labelContainer.length && this.labelContainer || $(this.currentForm); 174 this.containers = $(this.settings.errorContainer).add(this.settings.errorLabelContainer); 175 this.submitted = {}; 176 this.valueCache = {}; 177 this.pendingRequest = 0; 178 this.pending = {}; 179 this.invalid = {}; 180 this.reset(); 181 var groups = (this.groups = {}); 182 $.each(this.settings.groups, function (key, value) { 183 $.each(value.split(/\s/), function (index, name) { 184 groups[name] = key; 185 }); 186 }); 187 var rules = this.settings.rules; 188 $.each(rules, function (key, value) { 189 rules[key] = $.validator.normalizeRule(value); 190 }); 191 function delegate(event) { 192 var validator = $.data(this[0].form, "validator"), eventType = "on" + event.type.replace(/^validate/, ""); 193 validator.settings[eventType] && validator.settings[eventType].call(validator, this[0]); 194 } 195 196 $(this.currentForm).validateDelegate(":text, :password, :file, select, textarea", "focusin focusout keyup", delegate).validateDelegate(":radio, :checkbox, select, option", "click", delegate); 197 if (this.settings.invalidHandler)$(this.currentForm).bind("invalid-form.validate", this.settings.invalidHandler); 198 }, form:function () { 199 this.checkForm(); 200 $.extend(this.submitted, this.errorMap); 201 this.invalid = $.extend({}, this.errorMap); 202 if (!this.valid())$(this.currentForm).triggerHandler("invalid-form", [this]); 203 this.showErrors(); 204 return this.valid(); 205 }, checkForm:function () { 206 this.prepareForm(); 207 for (var i = 0, elements = (this.currentElements = this.elements()); elements[i]; i++) { 208 this.check(elements[i]); 209 } 210 return this.valid(); 211 }, element:function (element) { 212 element = this.clean(element); 213 this.lastElement = element; 214 this.prepareElement(element); 215 this.currentElements = $(element); 216 var result = this.check(element); 217 if (result) { 218 delete this.invalid[element.name]; 219 } else { 220 this.invalid[element.name] = true; 221 } 222 if (!this.numberOfInvalids()) { 223 this.toHide = this.toHide.add(this.containers); 224 } 225 this.showErrors(); 226 return result; 227 }, showErrors:function (errors) { 228 if (errors) { 229 $.extend(this.errorMap, errors); 230 this.errorList = []; 231 for (var name in errors) { 232 this.errorList.push({message:errors[name], element:this.findByName(name)[0]}); 233 } 234 this.successList = $.grep(this.successList, function (element) { 235 return!(element.name in errors); 236 }); 237 } 238 this.settings.showErrors ? this.settings.showErrors.call(this, this.errorMap, this.errorList) : this.defaultShowErrors(); 239 }, resetForm:function () { 240 if ($.fn.resetForm)$(this.currentForm).resetForm(); 241 this.submitted = {}; 242 this.prepareForm(); 243 this.hideErrors(); 244 this.elements().removeClass(this.settings.errorClass); 245 }, numberOfInvalids:function () { 246 return this.objectLength(this.invalid); 247 }, objectLength:function (obj) { 248 var count = 0; 249 for (var i in obj)count++; 250 return count; 251 }, hideErrors:function () { 252 this.addWrapper(this.toHide).hide(); 253 }, valid:function () { 254 return this.size() == 0;
255 }, size:function () { 256 return this.errorList.length; 257 }, focusInvalid:function () { 258 if (this.settings.focusInvalid) { 259 try { 260 $(this.findLastActive() || this.errorList.length && this.errorList[0].element || []).filter(":visible").focus().trigger("focusin"); 261 } catch (e) { 262 } 263 } 264 }, findLastActive:function () { 265 var lastActive = this.lastActive; 266 return lastActive && $.grep(this.errorList, 267 function (n) { 268 return n.element.name == lastActive.name; 269 }).length == 1 && lastActive; 270 }, elements:function () { 271 var validator = this, rulesCache = {}; 272 return $([]).add(this.currentForm.elements).filter(":input").not(":submit, :reset, :image, [disabled]").not(this.settings.ignore).filter(function () { 273 !this.name && validator.settings.debug && window.console && console.error("%o has no name assigned", this); 274 if (this.name in rulesCache || !validator.objectLength($(this).rules()))return false; 275 rulesCache[this.name] = true; 276 return true; 277 }); 278 }, clean:function (selector) { 279 return $(selector)[0]; 280 }, errors:function () { 281 return $(this.settings.errorElement + "." + this.settings.errorClass, this.errorContext); 282 }, reset:function () { 283 this.successList = []; 284 this.errorList = []; 285 this.errorMap = {}; 286 this.toShow = $([]); 287 this.toHide = $([]); 288 this.currentElements = $([]); 289 }, prepareForm:function () { 290 this.reset(); 291 this.toHide = this.errors().add(this.containers); 292 }, prepareElement:function (element) { 293 this.reset(); 294 this.toHide = this.errorsFor(element); 295 }, check:function (element) { 296 element = this.clean(element); 297 if (this.checkable(element)) { 298 element = this.findByName(element.name)[0]; 299 } 300 var rules = $(element).rules(); 301 var dependencyMismatch = false; 302 for (method in rules) { 303 var rule = {method:method, parameters:rules[method]}; 304 try { 305 var result = $.validator.methods[method].call(this, element.value.replace(/\r/g, ""), element, rule.parameters); 306 if (result == "dependency-mismatch") { 307 dependencyMismatch = true; 308 continue; 309 } 310 dependencyMismatch = false; 311 if (result == "pending") { 312 this.toHide = this.toHide.not(this.errorsFor(element)); 313 return; 314 } 315 if (!result) { 316 this.formatAndAdd(element, rule); 317 return false; 318 } 319 } catch (e) { 320 this.settings.debug && window.console && console.log("exception occured when checking element " + element.id 321 + ", check the '" + rule.method + "' method", e); 322 throw e; 323 } 324 } 325 if (dependencyMismatch)return; 326 if (this.objectLength(rules))this.successList.push(element); 327 return true; 328 }, customMetaMessage:function (element, method) { 329 if (!$.metadata)return; 330 var meta = this.settings.meta ? $(element).metadata()[this.settings.meta] : $(element).metadata(); 331 return meta && meta.messages && meta.messages[method]; 332 }, customMessage:function (name, method) { 333 var m = this.settings.messages[name]; 334 return m && (m.constructor == String ? m : m[method]); 335 }, findDefined:function () { 336 for (var i = 0; i < arguments.length; i++) { 337 if (arguments[i] !== undefined)return arguments[i]; 338 } 339 return undefined; 340 }, defaultMessage:function (element, method) { 341 return this.findDefined(this.customMessage(element.name, method), this.customMetaMessage(element, method), !this.settings.ignoreTitle && element.title || undefined, $.validator.messages[method], "<strong>Warning: No message defined for " + element.name + "</strong>"); 342 }, formatAndAdd:function (element, rule) { 343 var message = this.defaultMessage(element, rule.method), theregex = /\$?\{(\d+)\}/g; 344 if (typeof message == "function") { 345 message = message.call(this, rule.parameters, element); 346 } else if (theregex.test(message)) { 347 message = jQuery.format(message.replace(theregex, '{$1}'), rule.parameters); 348 } 349 this.errorList.push({message:message, element:element}); 350 this.errorMap[element.name] = message; 351 this.submitted[element.name] = message; 352 }, addWrapper:function (toToggle) { 353 if (this.settings.wrapper)toToggle = toToggle.add(toToggle.parent(this.settings.wrapper)); 354 return toToggle; 355 }, defaultShowErrors:function () { 356 for (var i = 0; this.errorList[i]; i++) { 357 var error = this.errorList[i]; 358 this.settings.highlight && this.settings.highlight.call(this, error.element, this.settings.errorClass, this.settings.val
358idClass); 359 this.showLabel(error.element, error.message); 360 } 361 if (this.errorList.length) { 362 this.toShow = this.toShow.add(this.containers); 363 } 364 if (this.settings.success) { 365 for (var i = 0; this.successList[i]; i++) { 366 this.showLabel(this.successList[i]); 367 } 368 } 369 if (this.settings.unhighlight) { 370 for (var i = 0, elements = this.validElements(); elements[i]; i++) { 371 this.settings.unhighlight.call(this, elements[i], this.settings.errorClass, this.settings.validClass); 372 } 373 } 374 this.toHide = this.toHide.not(this.toShow); 375 this.hideErrors(); 376 this.addWrapper(this.toShow).show(); 377 }, validElements:function () { 378 return this.currentElements.not(this.invalidElements()); 379 }, invalidElements:function () { 380 return $(this.errorList).map(function () { 381 return this.element; 382 }); 383 }, showLabel:function (element, message) { 384 var label = this.errorsFor(element); 385 if (label.length) { 386 label.removeClass().addClass(this.settings.errorClass); 387 label.attr("generated") && label.html(message); 388 } else { 389 label = $("<" + this.settings.errorElement + "/>").attr({"for":this.idOrName(element), generated:true}).addClass(this.settings.errorClass).html(message || ""); 390 if (this.settings.wrapper) { 391 label = label.hide().show().wrap("<" + this.settings.wrapper + "/>").parent(); 392 } 393 if (!this.labelContainer.append(label).length)this.settings.errorPlacement ? this.settings.errorPlacement(label, $(element)) : label.insertAfter(element); 394 } 395 if (!message && this.settings.success) { 396 label.text(""); 397 typeof this.settings.success == "string" ? label.addClass(this.settings.success) : this.settings.success(label); 398 } 399 this.toShow = this.toShow.add(label); 400 }, errorsFor:function (element) { 401 var name = this.idOrName(element); 402 return this.errors().filter(function () { 403 return $(this).attr('for') == name; 404 }); 405 }, idOrName:function (element) { 406 return this.groups[element.name] || (this.checkable(element) ? element.name : element.id || element.name); 407 }, checkable:function (element) { 408 return/radio|checkbox/i.test(element.type); 409 }, findByName:function (name) { 410 var form = this.currentForm; 411 return $(document.getElementsByName(name)).map(function (index, element) { 412 return element.form == form && element.name == name && element || null; 413 }); 414 }, getLength:function (value, element) { 415 switch (element.nodeName.toLowerCase()) { 416 case'select': 417 return $("option:selected", element).length; 418 case'input': 419 if (this.checkable(element))return this.findByName(element.name).filter(':checked').length; 420 } 421 return value.length; 422 }, depend:function (param, element) { 423 return this.dependTypes[typeof param] ? this.dependTypes[typeof param](param, element) : true; 424 }, dependTypes:{"boolean":function (param, element) { 425 return param; 426 }, "string":function (param, element) { 427 return!!$(param, element.form).length; 428 }, "function":function (param, element) { 429 return param(element); 430 }}, optional:function (element) { 431 return!$.validator.methods.required.call(this, $.trim(element.value), element) && "dependency-mismatch"; 432 }, startRequest:function (element) { 433 if (!this.pending[element.name]) { 434 this.pendingRequest++; 435 this.pending[element.name] = true; 436 } 437 }, stopRequest:function (element, valid) { 438 this.pendingRequest--; 439 if (this.pendingRequest < 0)this.pendingRequest = 0; 440 delete this.pending[element.name]; 441 if (valid && this.pendingRequest == 0 && this.formSubmitted && this.form()) { 442 $(this.currentForm).submit(); 443 this.formSubmitted = false; 444 } else if (!valid && this.pendingRequest == 0 && this.formSubmitted) { 445 $(this.currentForm).triggerHandler("invalid-form", [this]); 446 this.formSubmitted = false; 447 } 448 }, previousValue:function (element) { 449 return $.data(element, "previousValue") || $.data(element, "previousValue", {old:null, valid:true, message:this.defaultMessage(element, "remote")}); 450 }}, classRuleSettings:{required:{required:true}, email:{email:true}, url:{url:true}, date:{date:true}, dateISO:{dateISO:true}, dateDE:{dateDE:true}, number:{number:true}, numberDE:{numberDE:true}, digits:{digits:true}, creditcard:{creditcard:true}}, addClassRules:function (className, rules) { 451 className.constructor == String ? this.classRuleSettings[className] = rules : $.extend(this.classRuleSettings, className); 452 }, classRules:function (element) { 453 var rules = {}; 454 var classes = $(element).attr('class'); 455 classes && $.each(classes.split(' '), function () { 456 if (this in $.validator.classRuleSettings) { 457 $.extend(rules, $.validator.classRuleSettings[this]); 458 } 459 }); 460 return rules; 461 }, attributeRules:function (element) { 462 var rules = {}; 463 var $element = $(element); 464 for (method in $.validator.methods) { 465 var value = $element.attr(method); 466 if (value) { 467 rules[method] = value; 468 } 469 } 470 if (rules.maxlength && /-1|2147483647|524288/.test(rules.maxlength)) { 471 delete rules.maxlength; 472 } 473 return rules; 474 }, metadataRules:function (element) { 475 if (!$.metadata)return{}; 476 var meta = $.data(element.form, 'validator').settings.meta; 477 return meta ? $(element).metadata()[meta] : $(element).metadata(); 478 }, staticRules:function (element) { 479 var rules = {};
480 var validator = $.data(element.form, 'validator'); 481 if (validator.settings.rules) { 482 rules = $.validator.normalizeRule(validator.settings.rules[element.name]) || {}; 483 } 484 return rules; 485 }, normalizeRules:function (rules, element) { 486 $.each(rules, function (prop, val) { 487 if (val === false) { 488 delete rules[prop]; 489 return; 490 } 491 if (val.param || val.depends) { 492 var keepRule = true; 493 switch (typeof val.depends) { 494 case"string": 495 keepRule = !!$(val.depends, element.form).length; 496 break; 497 case"function": 498 keepRule = val.depends.call(element, element); 499 break; 500 } 501 if (keepRule) { 502 rules[prop] = val.param !== undefined ? val.param : true; 503 } else { 504 delete rules[prop]; 505 } 506 } 507 }); 508 $.each(rules, function (rule, parameter) { 509 rules[rule] = $.isFunction(parameter) ? parameter(element) : parameter; 510 }); 511 $.each(['minlength', 'maxlength', 'min', 'max'], function () { 512 if (rules[this]) { 513 rules[this] = Number(rules[this]); 514 } 515 }); 516 $.each(['rangelength', 'range'], function () { 517 if (rules[this]) { 518 rules[this] = [Number(rules[this][0]), Number(rules[this][1])]; 519 } 520 }); 521 if ($.validator.autoCreateRanges) { 522 if (rules.min && rules.max) { 523 rules.range = [rules.min, rules.max]; 524 delete rules.min; 525 delete rules.max; 526 } 527 if (rules.minlength && rules.maxlength) { 528 rules.rangelength = [rules.minlength, rules.maxlength]; 529 delete rules.minlength; 530 delete rules.maxlength; 531 } 532 } 533 if (rules.messages) { 534 delete rules.messages; 535 } 536 return rules; 537 }, normalizeRule:function (data) { 538 if (typeof data == "string") { 539 var transformed = {}; 540 $.each(data.split(/\s/), function () { 541 transformed[this] = true; 542 }); 543 data = transformed; 544 } 545 return data; 546 }, addMethod:function (name, method, message) { 547 $.validator.methods[name] = method; 548 $.validator.messages[name] = message != undefined ? message : $.validator.messages[name]; 549 if (method.length < 3) { 550 $.validator.addClassRules(name, $.validator.normalizeRule(name)); 551 } 552 }, methods:{required:function (value, element, param) { 553 if (!this.depend(param, element))return"dependency-mismatch"; 554 switch (element.nodeName.toLowerCase()) { 555 case'select': 556 var val = $(element).val(); 557 return val && val.length > 0; 558 case'input': 559 if (this.checkable(element))return this.getLength(value, element) > 0; 560 default: 561 return $.trim(value).length > 0; 562 } 563 }, remote:function (value, element, param) { 564 if (this.optional(element))return"dependency-mismatch"; 565 var previous = this.previousValue(element); 566 if (!this.settings.messages[element.name])this.settings.messages[element.name] = {}; 567 previous.originalMessage = this.settings.messages[element.name].remote; 568 this.settings.messages[element.name].remote = previous.message; 569 param = typeof param == "string" && {url:param} || param; 570 if (previous.old !== value) { 571 previous.old = value; 572 var validator = this; 573 this.startRequest(element); 574 var data = {}; 575 data[element.name] = value; 576 $.ajax($.extend(true, {url:param, mode:"abort", port:"validate" + element.name, dataType:"json", data:data, success:function (response) { 577 validator.settings.messages[element.name].remote = previous.originalMessage; 578 var valid = response === true; 579 if (valid) { 580 var submitted = validator.formSubmitted; 581 validator.prepareElement(element); 582 validator.formSubmitted = submitted; 583 validator.successList.push(element); 584 validator.showErrors(); 585 } else { 586 var errors = {}; 587 var message = (previous.message = response || validator.defaultMessage(element, "remote")); 588 errors[element.name] = $.isFunction(message) ? message(value) : message; 589 validator.showErrors(errors); 590 } 591 previous.valid = valid; 592 validator.stopRequest(element, valid); 593 }}, param)); 594 return"pending"; 595 } else if (this.pending[element.name]) { 596 return"pending"; 597 } 598 return previous.valid; 599 }, minlength:function (value, element, param) { 600 return this.optional(element) || this.getLength($.trim(value), element) >= param; 601 }, maxlength:function (value, element, param) { 602 return this.optional(element) || this.getLength($.trim(value), element) <= param; 603 }, rangelength:function (value, element, param) { 604 var length = this.getLength($.trim(value), element); 605 return this.optional(element) || (length >= param[0] && length <= param[1]); 606 }, min:function (value, element, param) { 607 return this.optional(element) || value >= param; 608 }, max:function (value, element, param) { 609 return this.optional(element) || value <= param; 610 }, range:function (value, element, param) { 611 return this.optional(element) || (value >= param[0] && value <= param[1]); 612 }, email:function (value, element) { 613 return this.optional(element) || /^((([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(value); 614 }, url:function (value, element) { 615 return this.optional(element) || /^(https?|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(value); 616 }, date:function (value, element) { 617 return this.optional(element) || !/Invalid|NaN/.test(new Date(value)); 618 }, dateISO:function (value, element) { 619 return this.optional(element) || /^\d{4}[\/-]\d{1,2}[\/-]\d{1,2}$/.test(value); 620 }, number:function (value, element) { 621 return this.optional(element) || /^-?(?:\d+|\d{1,3}(?:,\d{3})+)(?:\.\d+)?$/.test(value); 622 }, digits:function (value, element) { 623 return this.optional(element) || /^\d+$/.test(value); 624 }, creditcard:function (value, element) { 625 if (this.optional(element))return"dependency-mismatch"; 626 if (/[^0-9-]+/.test(value))return false; 627 var nCheck = 0, nDigit = 0, bEven = false; 628 value = value.replace(/\D/g, ""); 629 for (var n = value.length - 1; n >= 0; n--) { 630 var cDigit = value.charAt(n); 631 var nDigit = parseInt(cDigit, 10); 632 if (bEven) { 633 if ((nDigit *= 2) > 9)nDigit -= 9; 634 } 635 nCheck += nDigit; 636 bEven = !bEven; 637 } 638 return(nCheck % 10) == 0;
639 }, accept:function (value, element, param) { 640 param = typeof param == "string" ? param.replace(/,/g, '|') : "png|jpe?g|gif"; 641 return this.optional(element) || value.match(new RegExp(".(" + param + ")$", "i")); 642 }, equalTo:function (value, element, param) { 643 var target = $(param).unbind(".validate-equalTo").bind("blur.validate-equalTo", function () { 644 $(element).valid(); 645 }); 646 return value == target.val(); 647 }}}); 648 $.format = $.validator.format; 649})(jQuery); 650; 651(function ($) { 652 var ajax = $.ajax; 653 var pendingRequests = {}; 654 $.ajax = function (settings) { 655 settings = $.extend(settings, $.extend({}, $.ajaxSettings, settings)); 656 var port = settings.port; 657 if (settings.mode == "abort") { 658 if (pendingRequests[port]) { 659 pendingRequests[port].abort(); 660 } 661 return(pendingRequests[port] = ajax.apply(this, arguments)); 662 } 663 return ajax.apply(this, arguments); 664 }; 665})(jQuery); 666; 667(function ($) { 668 if (!jQuery.event.special.focusin && !jQuery.event.special.focusout && document.addEventListener) { 669 $.each({focus:'focusin', blur:'focusout'}, function (original, fix) { 670 $.event.special[fix] = {setup:function () { 671 this.addEventListener(original, handler, true); 672 }, teardown:function () { 673 this.removeEventListener(original, handler, true); 674 }, handler:function (e) { 675 arguments[0] = $.event.fix(e); 676 arguments[0].type = fix; 677 return $.event.handle.apply(this, arguments); 678 }}; 679 function handler(e) { 680 e = $.event.fix(e); 681 e.type = fix; 682 return $.event.handle.call(this, e); 683 } 684 }); 685 } 686 ; 687 $.extend($.fn, {validateDelegate:function (delegate, type, handler) { 688 return this.bind(type, function (event) { 689 var target = $(event.target); 690 if (target.is(delegate)) { 691 return handler.apply(target, arguments); 692 } 693 }); 694 }}); 695})(jQuery);
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.