Skip to content

Commit

Permalink
Fixes #3606, field revalidation would cause whole form to be revalidated
Browse files Browse the repository at this point in the history
  • Loading branch information
jlukic committed Feb 29, 2016
1 parent 1b341b2 commit e9aca44
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
2 changes: 2 additions & 0 deletions RELEASE-NOTES.md
Expand Up @@ -14,7 +14,9 @@
- **API** - Fixed bug causing `cache: 'local'` not to return the localstorage cached results in some cases
- **API** - Fixes bug where `beforeSend` would not correctly cancel request when `return false;` is used in callback. #3660
- **Dropdown** - Fixed bug where `search selection` would not let you move back in an entered search string with left arrow #3596 **Thanks @Sanjo**
-**Form Validation** - Fixed issue where revalidating a field `on:blur` could cause fields not yet interacted with to be validated #3606
-**Form Validation / Dropdown** - Fixed issue where using "enter" key in a `search dropdown` could cause a form to be submitted #3676
-**Search** - Fixed issue where a previous unfinished XHR query aborting would cause the next query to fail #2779
-**Divider** - Fixed issue where descenders like "g" would be cut off in `horizontal divider` #3585

**Bugs**
Expand Down
9 changes: 6 additions & 3 deletions src/definitions/behaviors/form.js
Expand Up @@ -299,7 +299,9 @@ $.fn.form = function(parameters) {
;
if( $fieldGroup.hasClass(className.error) ) {
module.debug('Revalidating field', $field, validationRules);
module.validate.form.call(module, event, true);
if(validationRules) {
module.validate.field( validationRules );
}
}
else if(settings.on == 'blur' || settings.on == 'change') {
if(validationRules) {
Expand All @@ -310,13 +312,14 @@ $.fn.form = function(parameters) {
change: function(event) {
var
$field = $(this),
$fieldGroup = $field.closest($group)
$fieldGroup = $field.closest($group),
validationRules = module.get.validation($field)
;
if(settings.on == 'change' || ( $fieldGroup.hasClass(className.error) && settings.revalidate) ) {
clearTimeout(module.timer);
module.timer = setTimeout(function() {
module.debug('Revalidating field', $field, module.get.validation($field));
module.validate.form.call(module, event, true);
module.validate.field( validationRules );
}, settings.delay);
}
}
Expand Down

0 comments on commit e9aca44

Please sign in to comment.