|
2 | 2 | * jQuery Form Validation |
3 | 3 | * |
4 | 4 | * @author Tom Bertrand |
5 | | - * @version 1.0.0 (2014-05-22) |
| 5 | + * @version 1.0.1 (2014-05-23) |
6 | 6 | * |
7 | 7 | * @copyright |
8 | 8 | * Copyright (C) 2014 Tom Bertrand. |
|
67 | 67 | 'DATE': '$ is not a valid with format YYYY-MM-DD.', |
68 | 68 | 'EMAIL': '$ is not valid.', |
69 | 69 | 'URL': '$ is not valid.', |
70 | | - 'PHONE': '$ is not a valid phone number', |
| 70 | + 'PHONE': '$ is not a valid phone number.', |
71 | 71 | //'INARRAY': '$ is not a valid option.', |
72 | 72 | '<': '$ must be less than % characters.', |
73 | 73 | '<=': '$ must be less or equal to % characters.', |
|
396 | 396 |
|
397 | 397 | } catch (error) { |
398 | 398 |
|
399 | | - if (validationMessage) { |
| 399 | + if (validationMessage || !options.submit.settings.allErrors) { |
400 | 400 | validateOnce = true; |
401 | 401 | } |
402 | 402 |
|
|
520 | 520 | return false; |
521 | 521 | } |
522 | 522 |
|
523 | | - if (!eval('"' + encodeURIComponent(value) + '"' + operator + '"' + encodeURIComponent(comparedValue) + '"')) { |
| 523 | + if (!value || !eval('"' + encodeURIComponent(value) + '"' + operator + '"' + encodeURIComponent(comparedValue) + '"')) { |
524 | 524 | throw [_message[operator], compared]; |
525 | 525 | } |
526 | 526 |
|
527 | 527 | } else { |
528 | 528 |
|
529 | | - if (eval(value.length + operator + parseFloat(compared)) == false) { |
| 529 | + if (!value || eval(value.length + operator + parseFloat(compared)) == false) { |
530 | 530 | throw [_message[operator], compared]; |
531 | 531 | } |
532 | 532 |
|
|
545 | 545 | return false; |
546 | 546 | } |
547 | 547 |
|
548 | | - if (!eval('"' + encodeURIComponent(value) + '"' + operator + '"' + encodeURIComponent(comparedValue) + '"')) { |
549 | | - throw [_message[operator], compared]; |
| 548 | + if (!value || !eval('"' + encodeURIComponent(value) + '"' + operator + '"' + encodeURIComponent(comparedValue) + '"')) { |
| 549 | + throw [_message[operator].replace(' characters', ''), compared]; |
550 | 550 | } |
551 | 551 |
|
552 | 552 | } else { |
553 | 553 |
|
554 | | - if (!eval(value + operator + parseFloat(compared))) { |
555 | | - throw [_message[operator], compared]; |
| 554 | + if (!value || !eval(value + operator + parseFloat(compared))) { |
| 555 | + throw [_message[operator].replace(' characters', ''), compared]; |
556 | 556 | } |
557 | 557 |
|
558 | 558 | } |
|
734 | 734 | (group ? label : input).parentsUntil(node, options.submit.settings.inputContainer).removeClass(options.submit.settings.errorClass) |
735 | 735 | } |
736 | 736 |
|
737 | | - label.removeClass(options.submit.settings.errorClass); |
| 737 | + label && label.removeClass(options.submit.settings.errorClass); |
738 | 738 |
|
739 | 739 | input.removeClass(options.submit.settings.errorClass); |
740 | 740 |
|
741 | | - |
742 | 741 | if (options.submit.settings.display === 'inline') { |
743 | 742 | container.find('[' + _data.errorList + ']').remove(); |
744 | 743 | } |
|
0 commit comments