1/** 2 * jQuery Validation Plugin 1.8.1 3 * 4 * http://bassistance.de/jquery-plugins/jquery-plugin-validation/ 5 * http://docs.jquery.com/Plugins/Validation 6 * 7 * Copyright (c) 2006 - 2011 Jörn Zaefferer 8 * 9 * Dual licensed under the MIT and GPL licenses: 10 * http://www.opensource.org/licenses/mit-license.php 11 * http://www.gnu.org/licenses/gpl.html 12 */ 13 14(function($) { 15 16$.extend($.fn, { 17 // http://docs.jquery.com/Plugins/Validation/validate 18 validate: function( options ) { 19 20 // if nothing is selected, return nothing; can't chain anyway 21 if (!this.length) { 22 options && options.debug && window.console && console.warn( "nothing selected, can't validate, returning nothing" ); 23 return; 24 } 25 26 // check if a validator for this form was already created 27 var validator = $.data(this[0], 'validator'); 28 if ( validator ) { 29 return validator; 30 } 31 32 validator = new $.validator( options, this[0] ); 33 $.data(this[0], 'validator', validator); 34 35 if ( validator.settings.onsubmit ) { 36 37 // allow suppresing validation by adding a cancel class to the submit button 38 this.find("input, button").filter(".cancel").click(function() { 39 validator.cancelSubmit = true; 40 }); 41 42 // when a submitHandler is used, capture the submitting button 43 if (validator.settings.submitHandler) { 44 this.find("input, button").filter(":submit").click(function() { 45 validator.submitButton = this; 46 }); 47 } 48 49 // validate the form on submit 50 this.submit( function( event ) { 51 if ( validator.settings.debug ) 52 // prevent form submit to be able to see console output 53 event.preventDefault(); 54 55 function handle() { 56 if ( validator.settings.submitHandler ) { 57 if (validator.submitButton) { 58 // insert a hidden input as a replacement for the missing submit button 59 var hidden = $("<input type='hidden'/>").attr("name", validator.submitButton.name).val(validator.submitButton.value).appendTo(validator.currentForm); 60 } 61 validator.settings.submitHandler.call( validator, validator.currentForm ); 62 if (validator.submitButton) { 63 // and clean up afterwards; thanks to no-block-scope, hidden can be referenced 64 hidden.remove(); 65 } 66 return false; 67 } 68 return true; 69 } 70 71 // prevent submit for invalid forms or custom submit handlers 72 if ( validator.cancelSubmit ) { 73 validator.cancelSubmit = false; 74 return handle(); 75 } 76 if ( validator.form() ) { 77 if ( validator.pendingRequest ) { 78 validator.formSubmitted = true; 79 return false; 80 } 81 return handle(); 82 } else { 83 validator.focusInvalid(); 84 return false; 85 } 86 }); 87 } 88 89 return validator; 90 }, 91 // http://docs.jquery.com/Plugins/Validation/valid 92 valid: function() { 93 if ( $(this[0]).is('form')) { 94 return this.validate().form(); 95 } else { 96 var valid = true; 97 var validator = $(this[0].form).validate(); 98 this.each(function() { 99 valid &= validator.element(this); 100 }); 101 return valid; 102 } 103 }, 104 // attributes: space seperated list of attributes to retrieve and remove 105 removeAttrs: function(attributes) { 106 var result = {}, 107 $element = this; 108 $.each(attributes.split(/\s/), function(index, value) { 109 result[value] = $element.attr(value); 110 $element.removeAttr(value); 111 }); 112 return result; 113 }, 114 // http://docs.jquery.com/Plugins/Validation/rules 115 rules: function(command, argument) { 116 var element = this[0]; 117 118 if (command) { 119 var settings = $.data(element.form, 'validator').settings; 120 var staticRules = settings.rules;
121 var existingRules = $.validator.staticRules(element); 122 switch(command) { 123 case "add": 124 $.extend(existingRules, $.validator.normalizeRule(argument)); 125 staticRules[element.name] = existingRules; 126 if (argument.messages) 127 settings.messages[element.name] = $.extend( settings.messages[element.name], argument.messages ); 128 break; 129 case "remove": 130 if (!argument) { 131 delete staticRules[element.name]; 132 return existingRules; 133 } 134 var filtered = {}; 135 $.each(argument.split(/\s/), function(index, method) { 136 filtered[method] = existingRules[method]; 137 delete existingRules[method]; 138 }); 139 return filtered; 140 } 141 } 142 143 var data = $.validator.normalizeRules( 144 $.extend( 145 {}, 146 $.validator.metadataRules(element), 147 $.validator.classRules(element), 148 $.validator.attributeRules(element), 149 $.validator.staticRules(element) 150 ), element); 151 152 // make sure required is at front 153 if (data.required) { 154 var param = data.required; 155 delete data.required; 156 data = $.extend({required: param}, data); 157 } 158 159 return data; 160 } 161}); 162 163// Custom selectors 164$.extend($.expr[":"], { 165 // http://docs.jquery.com/Plugins/Validation/blank 166 blank: function(a) {return !$.trim("" + a.value);}, 167 // http://docs.jquery.com/Plugins/Validation/filled 168 filled: function(a) {return !!$.trim("" + a.value);}, 169 // http://docs.jquery.com/Plugins/Validation/unchecked 170 unchecked: function(a) {return !a.checked;} 171}); 172 173// constructor for validator 174$.validator = function( options, form ) { 175 this.settings = $.extend( true, {}, $.validator.defaults, options ); 176 this.currentForm = form; 177 this.init(); 178}; 179 180$.validator.format = function(source, params) { 181 if ( arguments.length == 1 ) 182 return function() { 183 var args = $.makeArray(arguments); 184 args.unshift(source); 185 return $.validator.format.apply( this, args ); 186 }; 187 if ( arguments.length > 2 && params.constructor != Array ) { 188 params = $.makeArray(arguments).slice(1); 189 } 190 if ( params.constructor != Array ) { 191 params = [ params ]; 192 } 193 $.each(params, function(i, n) { 194 source = source.replace(new RegExp("\\{" + i + "\\}", "g"), n); 195 }); 196 return source; 197}; 198 199$.extend($.validator, { 200 201 defaults: { 202 messages: {}, 203 groups: {}, 204 rules: {}, 205 errorClass: "error", 206 validClass: "valid", 207 errorElement: "label", 208 focusInvalid: true, 209 errorContainer: $( [] ), 210 errorLabelContainer: $( [] ), 211 onsubmit: true, 212 ignore: [], 213 ignoreTitle: false, 214 onfocusin: function(element) { 215 this.lastActive = element; 216 217 // hide error label and remove error class on focus if enabled 218 if ( this.settings.focusCleanup && !this.blockFocusCleanup ) { 219 this.settings.unhighlight && this.settings.unhighlight.call( this, element, this.settings.errorClass, this.settings.validClass ); 220 this.addWrapper(this.errorsFor(element)).hide(); 221 } 222 }, 223 onfocusout: function(element) { 224 if ( !this.checkable(element) && (element.name in this.submitted || !this.optional(element)) ) { 225 this.element(element); 226 } 227 }, 228 onkeyup: function(element) { 229 if ( element.name in this.submitted || element == this.lastElement ) { 230 this.element(element); 231 } 232 }, 233 onclick: function(element) { 234 // click on selects, radiobuttons and checkboxes 235 if ( element.name in this.submitted )
236 this.element(element); 237 // or option elements, check parent select in that case 238 else if (element.parentNode.name in this.submitted) 239 this.element(element.parentNode); 240 }, 241 highlight: function(element, errorClass, validClass) { 242 if (element.type === 'radio') { 243 this.findByName(element.name).addClass(errorClass).removeClass(validClass); 244 } else { 245 $(element).addClass(errorClass).removeClass(validClass); 246 } 247 }, 248 unhighlight: function(element, errorClass, validClass) { 249 if (element.type === 'radio') { 250 this.findByName(element.name).removeClass(errorClass).addClass(validClass); 251 } else { 252 $(element).removeClass(errorClass).addClass(validClass); 253 } 254 } 255 }, 256 257 // http://docs.jquery.com/Plugins/Validation/Validator/setDefaults 258 setDefaults: function(settings) { 259 $.extend( $.validator.defaults, settings ); 260 }, 261 262 messages: { 263 required: "æ¤é¡¹ä¸ºå¿ 填项", 264 remote: "æ°æ®å·²åå¨", 265 email: "请è¾å ¥ä¸ä¸ªææççµåé®ä»¶å°å", 266 url: "请è¾å ¥ä¸ä¸ªææçç½å", 267 date: "请è¾å ¥ä¸ä¸ªææçæ¥æ", 268 dateISO: "请è¾å ¥ä¸ä¸ªææç(ISO)æ¥æ.", 269 number: "请è¾å ¥æ°å", 270 digits: "请åªè¾å ¥æ°å", 271 creditcard: "请è¾å ¥ä¸ä¸ªææçä¿¡ç¨å¡å·ç ", 272 creditcard: "请è¾å ¥ä¸ä¸ªææçä¿¡ç¨å¡å·ç ", 273 equalTo: "è¯·åæ¬¡è¾å ¥ç¸åçå¼.", 274 accept: "请è¾å ¥ä¸ä¸ªææçæ©å±åçä»·å¼.", 275 maxlength: $.validator.format("请è¾å ¥ä¸è¶ è¿ {0} 个å符."), 276 minlength: $.validator.format("请è¾å ¥è³å° {0} 个å符."), 277 rangelength: $.validator.format("请è¾å ¥ä»äºå¼ {0} å {1} 个å符é¿."), 278 range: $.validator.format("请è¾å ¥ä»äº {0} å {1}çå¼"), 279 max: $.validator.format("请è¾å ¥å¤§äºæçäº {0}çå¼"), 280 min: $.validator.format("请è¾å ¥ä¸ä¸ªå¼å¤§äºæçäº {0}çå¼"), 281 ip4: "请è¾å ¥æ£ç¡®çIPå°å", 282 mobile: "ææºå·ä¸æ£ç¡®", 283 zipcode: "é®ç®±æ ¼å¼é误", 284 qq: "QQå·ç æ ¼å¼é误", 285 idcard: "身份è¯å·æ ¼å¼é误", 286 chinese: "请è¾å ¥ä¸æå符", 287 cn_username:"请è¾å ¥ä¸æè±æåæ°å", 288 tel: "请è¾å ¥æ£ç¡®ççµè¯å·ç ", 289 english: "åªè½è¾å ¥è±æåæ¯", 290 english2: "ä¸è½è¾å ¥ä¸æ", 291 en_num: "åªè½è¾å ¥è±æåæ°ååä¸å线" 292 }, 293 294 295 autoCreateRanges: false, 296 297 prototype: { 298 299 init: function() { 300 this.labelContainer = $(this.settings.errorLabelContainer); 301 this.errorContext = this.labelContainer.length && this.labelContainer || $(this.currentForm); 302 this.containers = $(this.settings.errorContainer).add( this.settings.errorLabelContainer ); 303 this.submitted = {}; 304 this.valueCache = {}; 305 this.pendingRequest = 0; 306 this.pending = {}; 307 this.invalid = {}; 308 this.reset(); 309 310 var groups = (this.groups = {}); 311 $.each(this.settings.groups, function(key, value) { 312 $.each(value.split(/\s/), function(index, name) { 313 groups[name] = key; 314 }); 315 }); 316 var rules = this.settings.rules; 317 $.each(rules, function(key, value) { 318 rules[key] = $.validator.normalizeRule(value); 319 }); 320 321 function delegate(event) { 322 var validator = $.data(this[0].form, "validator"), 323 eventType = "on" + event.type.replace(/^validate/, ""); 324 validator.settings[eventType] && validator.settings[eventType].call(validator, this[0] ); 325 } 326 $(this.currentForm) 327 .validateDelegate(":text, :password, :file, select, textarea", "focusin focusout keyup", delegate) 328 .validateDelegate(":radio, :checkbox, select, option", "click", delegate); 329 330 if (this.settings.invalidHandler) 331 $(this.currentForm).bind("invalid-form.validate", this.settings.invalidHandler); 332 }, 333 334 // http://docs.jquery.com/Plugins/Validation/Validator/form 335 form: function() { 336 this.checkForm(); 337 $.extend(this.submitted, this.errorMap); 338 this.invalid = $.extend({}, this.errorMap); 339 if (!this.valid()) 340 $(this.currentForm).triggerHandler("invalid-form", [this]); 341 this.showErrors(); 342 return this.valid(); 343 }, 344 345 checkForm: function() { 346 this.prepareForm(); 347 for ( var i = 0, elements = (this.currentElements = this.elements()); elements[i]; i++ ) { 348 this.check( elements[i] ); 349 } 350 return this.valid(); 351 }, 352 353 // http://docs.jquery.com/Plugins/Validation/Validator/element 354 element: function( element ) { 355 element = this.clean( element ); 356 this.lastElement = element; 357 this.prepareElement( element ); 358 this.currentElements = $(element); 359 var result = this.check( element ); 360 if ( result ) { 361 delete this.invalid[element.name]; 362 } else { 363 this.invalid[element.name] = true; 364 } 365 if ( !this.numberOfInvalids() ) { 366 // Hide error containers on last error 367 this.toHide = this.toHide.add( this.containers ); 368 } 369 this.showErrors(); 370 return result; 371 }, 372 373 // http://docs.jquery.com/Plugins/Validation/Validator/showErrors 374 showErrors: function(errors) { 375 if(errors) { 376 // add items to error list and map 377 $.extend( this.errorMap, errors ); 378 this.errorList = []; 379 for ( var name in errors ) { 380 this.errorList.push({ 381 message: errors[name], 382 element: this.findByName(name)[0] 383 }); 384 } 385 // remove items from success list 386 this.successList = $.grep( this.successList, function(element) { 387 return !(element.name in errors); 388 }); 389 } 390 this.settings.showErrors 391 ? this.settings.showErrors.call( this, this.errorMap, this.errorList ) 392 : this.defaultShowErrors(); 393 }, 394 395 // http://docs.jquery.com/Plugins/Validation/Validator/resetForm 396 resetForm: function() { 397 if ( $.fn.resetForm ) 398 $( this.currentForm ).resetForm(); 399 this.submitted = {}; 400 this.prepareForm(); 401 this.hideErrors(); 402 this.elements().removeClass( this.settings.errorClass ); 403 }, 404 405 numberOfInvalids: function() { 406 return this.objectLength(this.invalid); 407 }, 408 409 objectLength: function( obj ) { 410 var count = 0; 411 for ( var i in obj ) 412 count++; 413 return count; 414 }, 415 416 hideErrors: function() { 417 this.addWrapper( this.toHide ).hide(); 418 }, 419 420 valid: function() { 421 return this.size() == 0;
422 }, 423 424 size: function() { 425 return this.errorList.length; 426 }, 427 428 focusInvalid: function() { 429 if( this.settings.focusInvalid ) { 430 try { 431 $(this.findLastActive() || this.errorList.length && this.errorList[0].element || []) 432 .filter(":visible") 433 .focus() 434 // manually trigger focusin event; without it, focusin handler isn't called, findLastActive won't have anything to find 435 .trigger("focusin"); 436 } catch(e) { 437 // ignore IE throwing errors when focusing hidden elements 438 } 439 } 440 }, 441 442 findLastActive: function() { 443 var lastActive = this.lastActive; 444 return lastActive && $.grep(this.errorList, function(n) { 445 return n.element.name == lastActive.name; 446 }).length == 1 && lastActive; 447 }, 448 449 elements: function() { 450 var validator = this, 451 rulesCache = {}; 452 453 // select all valid inputs inside the form (no submit or reset buttons) 454 return $(this.currentForm) 455 .find("input, select, textarea") 456 .not(":submit, :reset, :image, [disabled]") 457 .not( this.settings.ignore ) 458 .filter(function() { 459 !this.name && validator.settings.debug && window.console && console.error( "%o has no name assigned", this); 460 461 // select only the first element for each name, and only those with rules specified 462 if ( this.name in rulesCache || !validator.objectLength($(this).rules()) ) 463 return false; 464 465 rulesCache[this.name] = true; 466 return true; 467 }); 468 }, 469 470 clean: function( selector ) { 471 return $( selector )[0]; 472 }, 473 474 errors: function() { 475 return $( this.settings.errorElement + "." + this.settings.errorClass, this.errorContext ); 476 }, 477 478 reset: function() { 479 this.successList = []; 480 this.errorList = []; 481 this.errorMap = {}; 482 this.toShow = $([]); 483 this.toHide = $([]); 484 this.currentElements = $([]); 485 }, 486 487 prepareForm: function() { 488 this.reset(); 489 this.toHide = this.errors().add( this.containers ); 490 }, 491 492 prepareElement: function( element ) { 493 this.reset(); 494 this.toHide = this.errorsFor(element); 495 }, 496 497 check: function( element ) { 498 element = this.clean( element ); 499 500 // if radio/checkbox, validate first element in group instead 501 if (this.checkable(element)) { 502 element = this.findByName( element.name ).not(this.settings.ignore)[0]; 503 } 504 505 var rules = $(element).rules(); 506 var dependencyMismatch = false; 507 for (var method in rules ) { 508 var rule = { method: method, parameters: rules[method] }; 509 try { 510 var result = $.validator.methods[method].call( this, element.value.replace(/\r/g, ""), element, rule.parameters ); 511 512 // if a method indicates that the field is optional and therefore valid, 513 // don't mark it as valid when there are no other rules 514 if ( result == "dependency-mismatch" ) { 515 dependencyMismatch = true; 516 continue; 517 } 518 dependencyMismatch = false; 519 520 if ( result == "pending" ) { 521 this.toHide = this.toHide.not( this.errorsFor(element) ); 522 return; 523 } 524 525 if( !result ) { 526 this.formatAndAdd( element, rule ); 527 return false; 528 } 529 } catch(e) { 530 this.settings.debug && window.console && console.log("exception occured when checking element " + element.i
530d 531 + ", check the '" + rule.method + "' method", e); 532 throw e; 533 } 534 } 535 if (dependencyMismatch) 536 return; 537 if ( this.objectLength(rules) ) 538 this.successList.push(element); 539 return true; 540 }, 541 542 // return the custom message for the given element and validation method 543 // specified in the element's "messages" metadata 544 customMetaMessage: function(element, method) { 545 if (!$.metadata) 546 return; 547 548 var meta = this.settings.meta 549 ? $(element).metadata()[this.settings.meta] 550 : $(element).metadata(); 551 552 return meta && meta.messages && meta.messages[method]; 553 }, 554 555 // return the custom message for the given element name and validation method 556 customMessage: function( name, method ) { 557 var m = this.settings.messages[name]; 558 return m && (m.constructor == String 559 ? m 560 : m[method]); 561 }, 562 563 // return the first defined argument, allowing empty strings 564 findDefined: function() { 565 for(var i = 0; i < arguments.length; i++) { 566 if (arguments[i] !== undefined) 567 return arguments[i]; 568 } 569 return undefined; 570 }, 571 572 defaultMessage: function( element, method) { 573 return this.findDefined( 574 this.customMessage( element.name, method ), 575 this.customMetaMessage( element, method ), 576 // title is never undefined, so handle empty string as undefined 577 !this.settings.ignoreTitle && element.title || undefined, 578 $.validator.messages[method], 579 "<strong>Warning: No message defined for " + element.name + "</strong>" 580 ); 581 }, 582 583 formatAndAdd: function( element, rule ) { 584 var message = this.defaultMessage( element, rule.method ), 585 theregex = /\$?\{(\d+)\}/g; 586 if ( typeof message == "function" ) { 587 message = message.call(this, rule.parameters, element); 588 } else if (theregex.test(message)) { 589 message = jQuery.format(message.replace(theregex, '{$1}'), rule.parameters); 590 } 591 this.errorList.push({ 592 message: message, 593 element: element 594 }); 595 596 this.errorMap[element.name] = message; 597 this.submitted[element.name] = message; 598 }, 599 600 addWrapper: function(toToggle) { 601 if ( this.settings.wrapper ) 602 toToggle = toToggle.add( toToggle.parent( this.settings.wrapper ) ); 603 return toToggle; 604 }, 605 606 defaultShowErrors: function() { 607 for ( var i = 0; this.errorList[i]; i++ ) { 608 var error = this.errorList[i]; 609 this.settings.highlight && this.settings.highlight.call( this, error.element, this.settings.errorClass, this.settings.validClass ); 610 this.showLabel( error.element, error.message ); 611 } 612 if( this.errorList.length ) { 613 this.toShow = this.toShow.add( this.containers ); 614 } 615 if (this.settings.success) { 616 for ( var i = 0; this.successList[i]; i++ ) { 617 this.showLabel( this.successList[i] ); 618 } 619 } 620 if (this.settings.unhighlight) { 621 for ( var i = 0, elements = this.validElements(); elements[i]; i++ ) { 622 this.settings.unhighlight.call( this, elements[i], this.settings.errorClass, this.settings.validClass ); 623 } 624 } 625 this.toHide = this.toHide.not( this.toShow ); 626 this.hideErrors(); 627 this.addWrapper( this.toShow ).show(); 628 }, 629 630 validElements: function() { 631 return this.currentElements.not(this.invalidElements()); 632 }, 633 634 invalidElements: function() { 635 return $(this.errorList).map(function() { 636 return this.element; 637 }); 638 }, 639 640 showLabel: function(element, message) { 641 var label = this.errorsFor( element ); 642 if ( label.length ) { 643 // refresh error/success class 644 label.removeClass().addClass( this.settings.errorClass ); 645 646 // check if we have a generated label, replace the message then 647 label.attr("generated") && label.html(message); 648 } else { 649 // create label 650 label = $("<" + this.settings.errorElement + "/>") 651 .attr({"for": this.idOrName(element), generated: true}) 652 .addClass(this.settings.errorClass) 653 .html(message || ""); 654 if ( this.settings.wrapper ) { 655 // make sure the element is visible, even in IE 656 // actually showing the wrapped element is handled elsewhere 657 label = label.hide().show().wrap("<" + this.settings.wrapper + "/>").parent(); 658 } 659 if ( !this.labelContainer.append(label).length ) 660 this.settings.errorPlacement 661 ? this.settings.errorPlacement(label, $(element) ) 662 : label.insertAfter(element); 663 } 664 if ( !message && this.settings.success ) { 665 label.text(""); 666 typeof this.settings.success == "string" 667 ? label.addClass( this.settings.success ) 668 : this.settings.success( label ); 669 } 670 this.toShow = this.toShow.add(label); 671 }, 672 673 errorsFor: function(element) { 674 var name = this.idOrName(element); 675 return this.errors().filter(function() { 676 return $(this).attr('for') == name; 677 }); 678 }, 679 680 idOrName: function(element) { 681 return this.groups[element.name] || (this.checkable(element) ? element.name : element.i
681d || element.name); 682 }, 683 684 checkable: function( element ) { 685 return /radio|checkbox/i.test(element.type); 686 }, 687 688 findByName: function( name ) { 689 // select by name and filter by form for performance over form.find("[name=...]") 690 var form = this.currentForm; 691 return $(document.getElementsByName(name)).map(function(index, element) { 692 return element.form == form && element.name == name && element || null; 693 }); 694 }, 695 696 getLength: function(value, element) { 697 switch( element.nodeName.toLowerCase() ) { 698 case 'select': 699 return $("option:selected", element).length; 700 case 'input': 701 if( this.checkable( element) ) 702 return this.findByName(element.name).filter(':checked').length; 703 } 704 return value.length; 705 }, 706 707 depend: function(param, element) { 708 return this.dependTypes[typeof param] 709 ? this.dependTypes[typeof param](param, element) 710 : true; 711 }, 712 713 dependTypes: { 714 "boolean": function(param, element) { 715 return param; 716 }, 717 "string": function(param, element) { 718 return !!$(param, element.form).length; 719 }, 720 "function": function(param, element) { 721 return param(element); 722 } 723 }, 724 725 optional: function(element) { 726 return !$.validator.methods.required.call(this, $.trim(element.value), element) && "dependency-mismatch"; 727 }, 728 729 startRequest: function(element) { 730 if (!this.pending[element.name]) { 731 this.pendingRequest++; 732 this.pending[element.name] = true; 733 } 734 }, 735 736 stopRequest: function(element, valid) { 737 this.pendingRequest--; 738 // sometimes synchronization fails, make sure pendingRequest is never < 0 739 if (this.pendingRequest < 0) 740 this.pendingRequest = 0; 741 delete this.pending[element.name]; 742 if ( valid && this.pendingRequest == 0 && this.formSubmitted && this.form() ) { 743 $(this.currentForm).submit(); 744 this.formSubmitted = false; 745 } else if (!valid && this.pendingRequest == 0 && this.formSubmitted) { 746 $(this.currentForm).triggerHandler("invalid-form", [this]); 747 this.formSubmitted = false; 748 } 749 }, 750 751 previousValue: function(element) { 752 return $.data(element, "previousValue") || $.data(element, "previousValue", { 753 old: null, 754 valid: true, 755 message: this.defaultMessage( element, "remote" ) 756 }); 757 } 758 759 }, 760 761 classRuleSettings: { 762 required: {required: true}, 763 email: {email: true}, 764 url: {url: true}, 765 date: {date: true}, 766 dateISO: {dateISO: true}, 767 dateDE: {dateDE: true}, 768 number: {number: true}, 769 numberDE: {numberDE: true}, 770 digits: {digits: true}, 771 creditcard: {creditcard: true}, 772 ip4: {ip4: true}, 773 zipcode: {zipcode: true}, 774 qq: {qq: true}, 775 idcard: {idcard: true}, 776 chinese: {chinese: true}, 777 cn_username: {cn_username: true}, 778 tel: {tel: true}, 779 mobile: {mobile: true}, 780 english: {english: true}, 781 english2: {english2: true}, 782 en_num: {en_num: true} 783 }, 784 785 addClassRules: function(className, rules) { 786 className.constructor == String ? 787 this.classRuleSettings[className] = rules : 788 $.extend(this.classRuleSettings, className); 789 }, 790 791 classRules: function(element) { 792 var rules = {}; 793 var classes = $(element).attr('class'); 794 classes && $.each(classes.split(' '), function() { 795 if (this in $.validator.classRuleSettings) { 796 $.extend(rules, $.validator.classRuleSettings[this]); 797 } 798 }); 799 return rules; 800 }, 801 802 attributeRules: function(element) { 803 var rules = {}; 804 var $element = $(element); 805 806 for (var method in $.validator.methods) { 807 var value = $element.attr(method); 808 if (value) { 809 rules[method] = value; 810 } 811 } 812 813 // maxlength may be returned as -1, 2147483647 (IE) and 524288 (safari) for text inputs 814 if (rules.maxlength && /-1|2147483647|524288/.test(rules.maxlength)) { 815 delete rules.maxlength; 816 } 817 818 return rules; 819 }, 820 821 metadataRules: function(element) { 822 if (!$.metadata) return {}; 823 824 var meta = $.data(element.form, 'validator').settings.meta; 825 return meta ? 826 $(element).metadata()[meta] : 827 $(element).metadata(); 828 }, 829 830 staticRules: function(element) { 831 var rules = {};
832 var validator = $.data(element.form, 'validator'); 833 if (validator.settings.rules) { 834 rules = $.validator.normalizeRule(validator.settings.rules[element.name]) || {}; 835 } 836 return rules; 837 }, 838 839 normalizeRules: function(rules, element) { 840 // handle dependency check 841 $.each(rules, function(prop, val) { 842 // ignore rule when param is explicitly false, eg. required:false 843 if (val === false) { 844 delete rules[prop]; 845 return; 846 } 847 if (val.param || val.depends) { 848 var keepRule = true; 849 switch (typeof val.depends) { 850 case "string": 851 keepRule = !!$(val.depends, element.form).length; 852 break; 853 case "function": 854 keepRule = val.depends.call(element, element); 855 break; 856 } 857 if (keepRule) { 858 rules[prop] = val.param !== undefined ? val.param : true; 859 } else { 860 delete rules[prop]; 861 } 862 } 863 }); 864 865 // evaluate parameters 866 $.each(rules, function(rule, parameter) { 867 rules[rule] = $.isFunction(parameter) ? parameter(element) : parameter; 868 }); 869 870 // clean number parameters 871 $.each(['minlength', 'maxlength', 'min', 'max'], function() { 872 if (rules[this]) { 873 rules[this] = Number(rules[this]); 874 } 875 }); 876 $.each(['rangelength', 'range'], function() { 877 if (rules[this]) { 878 rules[this] = [Number(rules[this][0]), Number(rules[this][1])]; 879 } 880 }); 881 882 if ($.validator.autoCreateRanges) { 883 // auto-create ranges 884 if (rules.min && rules.max) { 885 rules.range = [rules.min, rules.max]; 886 delete rules.min; 887 delete rules.max; 888 } 889 if (rules.minlength && rules.maxlength) { 890 rules.rangelength = [rules.minlength, rules.maxlength]; 891 delete rules.minlength; 892 delete rules.maxlength; 893 } 894 } 895 896 // To support custom messages in metadata ignore rule methods titled "messages" 897 if (rules.messages) { 898 delete rules.messages; 899 } 900 901 return rules; 902 }, 903 904 // Converts a simple string to a {string: true} rule, e.g., "required" to {required:true} 905 normalizeRule: function(data) { 906 if( typeof data == "string" ) { 907 var transformed = {}; 908 $.each(data.split(/\s/), function() { 909 transformed[this] = true; 910 }); 911 data = transformed; 912 } 913 return data; 914 }, 915 916 // http://docs.jquery.com/Plugins/Validation/Validator/addMethod 917 addMethod: function(name, method, message) { 918 $.validator.methods[name] = method; 919 $.validator.messages[name] = message != undefined ? message : $.validator.messages[name]; 920 if (method.length < 3) { 921 $.validator.addClassRules(name, $.validator.normalizeRule(name)); 922 } 923 }, 924 925 methods: { 926 927 // http://docs.jquery.com/Plugins/Validation/Methods/required 928 required: function(value, element, param) { 929 // check if dependency is met 930 if ( !this.depend(param, element) ) 931 return "dependency-mismatch"; 932 switch( element.nodeName.toLowerCase() ) { 933 case 'select': 934 // could be an array for select-multiple or a string, both are fine this way 935 var val = $(element).val(); 936 return val && val.length > 0; 937 case 'input': 938 if ( this.checkable(element) ) 939 return this.getLength(value, element) > 0; 940 default: 941 return $.trim(value).length > 0; 942 } 943 }, 944 945 // http://docs.jquery.com/Plugins/Validation/Methods/remote 946 remote: function(value, element, param) { 947 if ( this.optional(element) ) 948 return "dependency-mismatch"; 949 950 var previous = this.previousValue(element); 951 if (!this.settings.messages[element.name] ) 952 this.settings.messages[element.name] = {}; 953 previous.originalMessage = this.settings.messages[element.name].remote; 954 this.settings.messages[element.name].remote = previous.message; 955 956 param = typeof param == "string" && {url:param} || param; 957 958 if ( this.pending[element.name] ) { 959 return "pending"; 960 } 961 if ( previous.old === value ) { 962 return previous.valid; 963 } 964 965 previous.old = value;
966 var validator = this; 967 this.startRequest(element); 968 var data = {}; 969 data[element.name] = value; 970 $.ajax($.extend(true, { 971 url: param, 972 mode: "abort", 973 port: "validate" + element.name, 974 dataType: "json", 975 data: data, 976 success: function(response) { 977 validator.settings.messages[element.name].remote = previous.originalMessage; 978 var valid = response === true; 979 if ( valid ) { 980 var submitted = validator.formSubmitted; 981 validator.prepareElement(element); 982 validator.formSubmitted = submitted; 983 validator.successList.push(element); 984 validator.showErrors(); 985 } else { 986 var errors = {}; 987 var message = response || validator.defaultMessage( element, "remote" ); 988 errors[element.name] = previous.message = $.isFunction(message) ? message(value) : message; 989 validator.showErrors(errors); 990 } 991 previous.valid = valid; 992 validator.stopRequest(element, valid); 993 } 994 }, param)); 995 return "pending"; 996 }, 997 998 // http://docs.jquery.com/Plugins/Validation/Methods/minlength 999 minlength: function(value, element, param) { 1000 return this.optional(element) || this.getLength($.trim(value), element) >= param; 1001 }, 1002 1003 // http://docs.jquery.com/Plugins/Validation/Methods/maxlength 1004 maxlength: function(value, element, param) { 1005 return this.optional(element) || this.getLength($.trim(value), element) <= param; 1006 }, 1007 1008 // http://docs.jquery.com/Plugins/Validation/Methods/rangelength 1009 rangelength: function(value, element, param) { 1010 var length = this.getLength($.trim(value), element); 1011 return this.optional(element) || ( length >= param[0] && length <= param[1] ); 1012 }, 1013 1014 // http://docs.jquery.com/Plugins/Validation/Methods/min 1015 min: function( value, element, param ) { 1016 return this.optional(element) || value >= param; 1017 }, 1018 1019 // http://docs.jquery.com/Plugins/Validation/Methods/max 1020 max: function( value, element, param ) { 1021 return this.optional(element) || value <= param; 1022 }, 1023 1024 // http://docs.jquery.com/Plugins/Validation/Methods/range 1025 range: function( value, element, param ) { 1026 return this.optional(element) || ( value >= param[0] && value <= param[1] ); 1027 }, 1028 1029 // http://docs.jquery.com/Plugins/Validation/Methods/email 1030 email: function(value, element) { 1031 // contributed by Scott Gonzalez: http://projects.scottsplayground.com/email_address_validation/ 1032 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); 1033 }, 1034 1035 // http://docs.jquery.com/Plugins/Validation/Methods/url 1036 url: function(value, element) { 1037 // contributed by Scott Gonzalez: http://projects.scottsplayground.com/iri/ 1038 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); 1039 }, 1040 1041 // http://docs.jquery.com/Plugins/Validation/Methods/date 1042 date: function(value, element) { 1043 return this.optional(element) || !/Invalid|NaN/.test(new Date(value)); 1044 }, 1045 1046 // http://docs.jquery.com/Plugins/Validation/Methods/dateISO 1047 dateISO: function(value, element) { 1048 return this.optional(element) || /^\d{4}[\/-]\d{1,2}[\/-]\d{1,2}$/.test(value); 1049 }, 1050 1051 // http://docs.jquery.com/Plugins/Validation/Methods/number 1052 number: function(value, element) { 1053 return this.optional(element) || /^-?(?:\d+|\d{1,3}(?:,\d{3})+)(?:\.\d+)?$/.test(value); 1054 }, 1055 english2:function(value, element){ 1056 return this.optional(element) || !/[\u4E00-\u9FA5]/i.test(value); 1057 }, 1058 english: function(value, element) { 1059 return this.optional(element) || /^[a-z_A-Z]+$/.test(value); 1060 }, 1061 en_num: function(value, element) { 1062 return this.optional(element) || /^\w+$/.test(value); 1063 }, 1064 ip4: function(value, element) { 1065 return this.optional(element) || /^\d+\.\d+\.\d+\.\d+$/.test(value); 1066 }, 1067 mobile: function(value, element) { 1068 return this.optional(element) || /^[0-9]{11}$/.test(value); 1069 }, 1070 zipcode: function(value, element) { 1071 return this.optional(element) || /^\d{6}$/.test(value); 1072 }, 1073 qq: function(value, element) { 1074 return this.optional(element) || /^\d{5,}$/.test(value); 1075 }, 1076 idcard: function(value, element) { 1077 return validateIdCard(value); 1078 }, 1079 chinese: function(value, element) { 1080 return this.optional(element) || /^[\u4e00-\u9fa5]+$/.test(value); 1081 }, 1082 cn_username: function(value, element) { 1083 return this.optional(element) || /^([\u4e00-\u9fa5]|[\w])+$/.test(value); 1084 }, 1085 tel: function(value, element) { 1086 return this.optional(element) || /^[+]{0,1}(\d){1,4}[ ]{0,1}([-]{0,1}((\d)|[ ]){1,12})+$/.test(value); 1087 }, 1088 1089 // http://docs.jquery.com/Plugins/Validation/Methods/digits 1090 digits: function(value, element) { 1091 return this.optional(element) || /^\d+$/.test(value); 1092 }, 1093 1094 // http://docs.jquery.com/Plugins/Validation/Methods/creditcard 1095 // based on http://en.wikipedia.org/wiki/Luhn 1096 creditcard: function(value, element) { 1097 if ( this.optional(element) ) 1098 return "dependency-mismatch"; 1099 // accept only digits and dashes 1100 if (/[^0-9-]+/.test(value)) 1101 return false; 1102 var nCheck = 0, 1103 nDigit = 0, 1104 bEven = false; 1105 1106 value = value.replace(/\D/g, ""); 1107 1108 for (var n = value.length - 1; n >= 0; n--) { 1109 var cDigit = value.charAt(n); 1110 var nDigit = parseInt(cDigit, 10); 1111 if (bEven) { 1112 if ((nDigit *= 2) > 9) 1113 nDigit -= 9; 1114 } 1115 nCheck += nDigit; 1116 bEven = !bEven; 1117 } 1118 1119 return (nCheck % 10) == 0;
1120 }, 1121 1122 // http://docs.jquery.com/Plugins/Validation/Methods/accept 1123 accept: function(value, element, param) { 1124 param = typeof param == "string" ? param.replace(/,/g, '|') : "png|jpe?g|gif"; 1125 return this.optional(element) || value.match(new RegExp(".(" + param + ")$", "i")); 1126 }, 1127 1128 // http://docs.jquery.com/Plugins/Validation/Methods/equalTo 1129 equalTo: function(value, element, param) { 1130 // bind to the blur event of the target in order to revalidate whenever the target field is updated 1131 // TODO find a way to bind the event just once, avoiding the unbind-rebind overhead 1132 var target = $(param).unbind(".validate-equalTo").bind("blur.validate-equalTo", function() { 1133 $(element).valid(); 1134 }); 1135 return value == target.val(); 1136 } 1137 1138 } 1139 1140}); 1141 1142// deprecated, use $.validator.format instead 1143$.format = $.validator.format; 1144 1145})(jQuery); 1146 1147// ajax mode: abort 1148// usage: $.ajax({ mode: "abort"[, port: "uniqueport"]}); 1149// if mode:"abort" is used, the previous request on that port (port can be undefined) is aborted via XMLHttpRequest.abort() 1150;(function($) { 1151 var pendingRequests = {}; 1152 // Use a prefilter if available (1.5+) 1153 if ( $.ajaxPrefilter ) { 1154 $.ajaxPrefilter(function(settings, _, xhr) { 1155 var port = settings.port; 1156 if (settings.mode == "abort") { 1157 if ( pendingRequests[port] ) { 1158 pendingRequests[port].abort(); 1159 } 1160 pendingRequests[port] = xhr; 1161 } 1162 }); 1163 } else { 1164 // Proxy ajax 1165 var ajax = $.ajax; 1166 $.ajax = function(settings) { 1167 var mode = ( "mode" in settings ? settings : $.ajaxSettings ).mode, 1168 port = ( "port" in settings ? settings : $.ajaxSettings ).port; 1169 if (mode == "abort") { 1170 if ( pendingRequests[port] ) { 1171 pendingRequests[port].abort(); 1172 } 1173 return (pendingRequests[port] = ajax.apply(this, arguments)); 1174 } 1175 return ajax.apply(this, arguments); 1176 }; 1177 } 1178})(jQuery); 1179 1180// provides cross-browser focusin and focusout events 1181// IE has native support, in other browsers, use event caputuring (neither bubbles) 1182 1183// provides delegate(type: String, delegate: Selector, handler: Callback) plugin for easier event delegation 1184// handler is only called when $(event.target).is(delegate), in the scope of the jquery-object for event.target 1185;(function($) { 1186 // only implement if not provided by jQuery core (since 1.4) 1187 // TODO verify if jQuery 1.4's implementation is compatible with older jQuery special-event APIs 1188 if (!jQuery.event.special.focusin && !jQuery.event.special.focusout && document.addEventListener) { 1189 $.each({ 1190 focus: 'focusin', 1191 blur: 'focusout' 1192 }, function( original, fix ){ 1193 $.event.special[fix] = { 1194 setup:function() { 1195 this.addEventListener( original, handler, true ); 1196 }, 1197 teardown:function() { 1198 this.removeEventListener( original, handler, true ); 1199 }, 1200 handler: function(e) { 1201 arguments[0] = $.event.fix(e); 1202 arguments[0].type = fix; 1203 return $.event.handle.apply(this, arguments); 1204 } 1205 }; 1206 function handler(e) { 1207 e = $.event.fix(e); 1208 e.type = fix; 1209 return $.event.handle.call(this, e); 1210 } 1211 }); 1212 }; 1213 $.extend($.fn, { 1214 validateDelegate: function(delegate, type, handler) { 1215 return this.bind(type, function(event) { 1216 var target = $(event.target); 1217 if (target.is(delegate)) { 1218 return handler.apply(target, arguments); 1219 } 1220 }); 1221 } 1222 });
1223})(jQuery); 1224 1225 1226 1227/*设置æ¾ç¤ºæ ·å¼*/ 1228 1229(function($) { 1230 1231$.extend({ 1232 metadata : { 1233 defaults : { 1234 type: 'class', 1235 name: 'metadata', 1236 cre: /({.*})/, 1237 single: 'metadata' 1238 }, 1239 setType: function( type, name ){ 1240 this.defaults.type = type; 1241 this.defaults.name = name; 1242 }, 1243 get: function( elem, opts ){ 1244 var settings = $.extend({},this.defaults,opts); 1245 // check for empty string in single property 1246 if ( !settings.single.length ) settings.single = 'metadata'; 1247 1248 var data = $.data(elem, settings.single); 1249 // returned cached data if it already exists 1250 if ( data ) return data; 1251 1252 data = "{}"; 1253 1254 if ( settings.type == "class" ) { 1255 var m = settings.cre.exec( elem.className ); 1256 if ( m ) 1257 data = m[1]; 1258 } else if ( settings.type == "elem" ) { 1259 if( !elem.getElementsByTagName ) 1260 return undefined; 1261 var e = elem.getElementsByTagName(settings.name); 1262 if ( e.length ) 1263 data = $.trim(e[0].innerHTML); 1264 } else if ( elem.getAttribute != undefined ) { 1265 var attr = elem.getAttribute( settings.name ); 1266 if ( attr ) 1267 data = attr; 1268 } 1269 1270 if ( data.indexOf( '{' ) <0 ) 1271 data = "{" + data + "}"; 1272 1273 data = eval("(" + data + ")"); 1274 1275 $.data( elem, settings.single, data ); 1276 return data; 1277 } 1278 } 1279}); 1280 1281 1282$.fn.metadata = function( opts ){ 1283 return $.metadata.get( this[0], opts ); 1284}; 1285 1286})(jQuery); 1287 1288$.metadata.setType("attr", "validate"); 1289 1290 1291 1292function validateIdCard(idCard){ 1293 //15ä½å18ä½èº«ä»½è¯å·ç çæ£åè¡¨è¾¾å¼ 1294 var regIdCard=/^(^[1-9]\d{7}((0\d)|(1[0-2]))(([0|1|2]\d)|3[0-1])\d{3}$)|(^[1-9]\d{5}[1-9]\d{3}((0\d)|(1[0-2]))(([0|1|2]\d)|3[0-1])((\d{4})|\d{3}[Xx])$)$/; 1295 1296 //妿éè¿è¯¥éªè¯ï¼è¯´æèº«ä»½è¯æ ¼å¼æ£ç¡®ï¼ä½åç¡®æ§è¿éè®¡ç® 1297 if(regIdCard.test(idCard)){ 1298 if(idCard.length==18){ 1299 var idCardWi=new Array( 7, 9, 10, 5, 8, 4, 2, 1, 6, 3, 7, 9, 10, 5, 8, 4, 2 ); //å°å17ä½å æå åä¿å卿°ç»é 1300 var idCardY=new Array( 1, 0, 10, 9, 8, 7, 6, 5, 4, 3, 2 ); //è¿æ¯é¤ä»¥11åï¼å¯è½äº§çç11ä½ä½æ°ãéªè¯ç ï¼ä¹ä¿åææ°ç» 1301 var idCardWiSum=0; //ç¨æ¥ä¿åå17ä½åèªä¹ä»¥å æå ååçæ»å 1302 for(var i=0;i<17;i++){ 1303 idCardWiSum+=idCard.substring(i,i+1)*idCardWi[i]; 1304 } 1305 1306 var idCardMod=idCardWiSum%11;//计ç®åºæ ¡éªç æå¨æ°ç»çä½ç½® 1307 var idCardLast=idCard.substring(17);//å¾å°æåä¸ä½èº«ä»½è¯å·ç 1308 1309 //妿çäº2ï¼åè¯´ææ ¡éªç æ¯10ï¼èº«ä»½è¯å·ç æåä¸ä½åºè¯¥æ¯X 1310 if(idCardMod==2){ 1311 if(idCardLast=="X"||idCardLast=="x"){ 1312 // alert("æåéè¿éªè¯å¦ï¼"); 1313 return true; 1314 }else{ 1315 // alert("身份è¯å·ç é误ï¼"); 1316 return false; 1317 } 1318 }else{ 1319 //ç¨è®¡ç®åºçéªè¯ç 䏿åä¸ä½èº«ä»½è¯å·ç å¹é ï¼å¦æä¸è´ï¼è¯´æéè¿ï¼å¦åæ¯æ æç身份è¯å·ç 1320 if(idCardLast==idCardY[idCardMod]){ 1321 // alert("æåéè¿éªè¯å¦ï¼"); 1322 return true; 1323 }else{ 1324 // alert("身份è¯å·ç é误ï¼"); 1325 return false; 1326 } 1327 } 1328 } 1329 }else{ 1330 // alert("èº«ä»½è¯æ ¼å¼ä¸æ£ç¡®!"); 1331 return false; 1332 } 1333}
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.