Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Knockout-validation doesn't show error message with 'textInput' binding #451

Closed
ThakkarHitesh opened this issue Sep 1, 2014 · 7 comments

Comments

@ThakkarHitesh
Copy link

The textInput binding has been added in the latest version of knockout.js. However when using it with knockout-validation, the validation rules do apply but the validation message(s) is not displayed in UI when invalid. In fact the span with validationMessage class is missing completely in DOM for the element where textInput binding is used.

@karlp
Copy link

karlp commented Sep 15, 2014

Confirmed, I'm seeing this with knockout 3.2 as well. Surpisingly, the span elements are sometimes created, but in the wrong place. (In one case, three s later, after a select, instead of on the textInput it should have been attached to)

Switching from textInput to value immediately makes the validation start working as expected.

The fiddle referred to from the homepage, http://jsfiddle.net/KHFn8/2971/ is an easy way of testing out the breakage

@waynebloss
Copy link

waynebloss commented Oct 1, 2014

This seems to work if you add an entry for "textInput" to the section starting at line 962 as shown below.

// override for KO's default 'value' and 'checked' bindings
kv.makeBindingHandlerValidatable("value");
kv.makeBindingHandlerValidatable("checked");
kv.makeBindingHandlerValidatable("textInput");
I did not test this very extensively.

However, it immediately fixed the issue for me. Looking at the definition of makeBindingHandlerValidatable on line 574, it simply intercepts the call to the original binding handler's init function, so that it can call the validationCore init function immediately after any of those binding handler's own init function is called.

@crissdev
Copy link
Member

@karlp @waynebloss a test for this is available in this commit.

@naveen4854
Copy link

I can see this issue still happening

@fcogutierrez
Copy link

This link doesn't work https://github.com/Knockout-Contrib/Knockout-Validation/blob/master/Dist/knockout.validation.js#L962

Please, can you tell me how can I fix this issue? Thanks in advance.

@waynebloss
Copy link

I updated the link to point to the source code that existed at the time of my comment in October of 2014.

Here is the new link to Line 962 of Dist/knockout.validation.js which shows you the section where you can add kv.makeBindingHandlerValidatable("textInput");.

However, this workaround only works for that version of the code. If you're using a newer version of Knockout, then I'm not sure what the problem is - I'm not using Knockout at this time.

@waynebloss
Copy link

It looks like the workaround was merged into Knockout by crissdev, which you can see in the 2 comments on October 31, 2014 and November 4, 2014.

The best thing to do in this case is to reproduce the problem using a tool like jsfiddle.net and then post a link to your reproduction in a new issue for the current version of Knockout that you're using.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants