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

callback validation not working when have default value #42

Closed
tongyi121 opened this issue Dec 20, 2012 · 4 comments
Closed

callback validation not working when have default value #42

tongyi121 opened this issue Dec 20, 2012 · 4 comments

Comments

@tongyi121
Copy link

I set a wrong defalut value,submit form immediately,then validation is not working.

@noxtras
Copy link

noxtras commented Dec 21, 2012

Hello,
Can you give me the URL of the page you're testing? I may be able to help you.

@ReactiveRaven
Copy link
Owner

@tongyi121 I'm afraid this is deliberate. Because validation needs to be instant, and your callback might take a while to respond (say you might be doing your own AJAX and the server goes down), the validator assumes the field is valid until it knows otherwise. When it gets a response, it re-runs the validation, but by then it might be too late.

Because you're setting the default value (in the HTML?), no events are triggered. This means the first time the validator checks the value is when 'submit' is clicked.

I'd suggest using the placeholder attribute for the default value, and making the field required.

Apologies for the badly worded documentation, I'm in the process of re-writing it.

@ReactiveRaven
Copy link
Owner

If the above doesn't help, feel free to re-open and add more information. Thanks

@rilkeanheart
Copy link

Hi. I'm having a similar issue using the callback (I'm using it to validate the date field). I am using placeholder and have made the field required- and the validation is correct when no input is given. If I type in an incorrect date, the callback is called and the error message shows. However, if I simply 'submit' the form at that point, the form submits with the bad date info. Am I using callback correctly? Is there any significance to the fact that the error message/label is "amber" after failing invalidation and not "red"? After I submit the message/label becomes "red".

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

4 participants