Skip to content
This repository has been archived by the owner on Mar 12, 2020. It is now read-only.

data-match validator not monitoring target field for changes #316

Closed
Jargon64 opened this issue Apr 15, 2016 · 5 comments
Closed

data-match validator not monitoring target field for changes #316

Jargon64 opened this issue Apr 15, 2016 · 5 comments
Labels

Comments

@Jargon64
Copy link

Think I've discovered a bug with the data-match validator. Take the example at http://jsbin.com/hisoha/6/edit?html,js,console,output

If you provide a valid email address in the first field, then retype the same email address in the second the validation works as expected. However, if you then go back to the first email field and enter in a completely different, yet valid, email address the validation still succeeds and the form can be submitted.

I assume this is due to the way the valid state is cached per field for optimisation purposes (after reading through other issues on this board).

The only way I can safely proceed is to put a data-match on both email fields (referencing the other), but then the form starts whining at you before you even get to the confirm email field.

@1000hz 1000hz added the bug label Apr 15, 2016
@1000hz
Copy link
Owner

1000hz commented Apr 15, 2016

Hmm, yeah. I'll investigate.

@marcelbonnet
Copy link

Hey, great project. I don't wanna be the one to echo "hey I found the same bug", but I was trying to implement a equlasgreater and equalslesser using the same approach of the "match" function and than I realized the same bug then happens to my new functions. So it would be really great to fix the mentioned bug.

@1000hz
Copy link
Owner

1000hz commented Apr 26, 2016

It's a result of the recent change that skips a field's validation if the input hasn't been touched. It needs to be smarter about it. I probably won't have time to fix it very soon.

@Jargon64
Copy link
Author

I've run into this issue a second time in a different project while creating a custom validator that depends on another field. Decided to take a look into the source code and saw that the cached result check and assignment is done before the validators are run. So what I ended up doing is clearing the cached result at the beginning of my custom validator knowing it will force the validator to run on the next check. The code I added to my validator is as follow:

$el.removeData('bs.validator.previous');

Hopefully this work around helps some people out.

@marcelbonnet
Copy link

Thanks @Jargon64 . I scheduled to take a look at the validator in a month, hope this work, I liked this validator. I'll also share any progress.

@1000hz 1000hz closed this as completed in fd5e80b Jul 15, 2016
1000hz added a commit that referenced this issue Jul 15, 2016
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

3 participants