Comments (11)
I'm also getting issues surrounding remote validation. I'm using the latest v1.7 version directly out of github, confirmed that I'm returning the correct "false" response.
Fields using remote validation get marked "valid" when submitting but block the form from being submitted. No error messages are displayed.
from jquery-validation.
When getting a succesful remote result after the field itself has no focus anymore, the invalid hash is not updated, only the successList. This results in a wrong count returned by numberOfInvalids().
from jquery-validation.
Ok, I've tracked it down a bit further. I've used 1.8 for this...
On line 950, in the 'success' function, validator.prepareElement(element) is called, which calls this.reset(), which assigns this.errorList = [];. This resets the size() of the validator, so that the form validates to true always.
On line, 958, also in the 'success' function, but when the remote check returns 'false', validator.showErrors(errors) is called with one error, namely the one returned from the remote. In this function, on line 357, there is the assignment this.errorList = [];. This resets the size() of the validator, so that the form has only one error, the one returned from the remote call.
So, in both cases, the error list is not what it should be after a remote validation.
Note that I am running a $('form').valid() from a button, I'm not 'submitting' the form per se.
AFAICS, this has (unfortunately) nothing to do with the field having focus or not.
from jquery-validation.
Similar to #286
from jquery-validation.
@cvwillegen @Rodeoclash @ArthurClemens can one of you provide a failing test case on jsfiddle or something that shows this issue, using the new version of validate in git? Thanks.
from jquery-validation.
Max,
On Sat, May 5, 2012 at 7:44 PM, Max Lynch
[email protected]
wrote:
@cvwillegen @Rodeoclash @ArthurClemens can one of you provide a failing test case on jsfiddle or something that shows this issue, using the new version of validate in git? Thanks.
I haven't been able to break it, yet, and I now use the 'stock'
jquery.validate.js from GitHub. We do use remote validation quite a
lot, and so far, no problems with remote (nor with local) validation.
Christ van Willegen
09 F9 11 02 9D 74 E3 5B D8 41 56 C5 63 56 88 C0
from jquery-validation.
I'm having a similar issue with remote - in my case, the remote will return correctly on an invalid element the first time. However, if the field has success, and I put in an invalid value - it never triggers the remote call again.
from jquery-validation.
The same issue here too. I changed my code a bit so the remote is only called on blur and not on keydown and validation is done only on blur.
Steps to reproduce (on latest 1.9.0):
- enter invalid data into a "remote" input field
- tab to next input field, so the invalid one looses focus / calling blur event. The input field should now getting a errorClass and the invalid label.
- goto previous input field and correct the invalid data
- tab again to next field, now the invalid label disappears because the data is valid, but the input field still has the errorClass instead of validClass.
I traced it down too to the thing cvwillegen reported a year ago:
validator.prepareElement(element) is called right after the success method of remote function, which calls reset(), and reset clears (amongst other things) currentElements[], but a a filled currentElements is required right before the call to validator.showErrors() in the success method. currentElements is required by validElements() used in defaultShowErrors() (line 614) to clear errorClass and set validClass (line 615).
Suggested fix:
After disabling the call to validator.prepareElement(element) in remote() success method to prevent reset() being called, it seems to fix my issue. Is this call required for something? Running the testcase afterwards didn't trigger any errors.
The code I used looks similar to this:
$('form').validate({
rules: {
username: {
required: true,
remote: {url: "index.php?action=isUsernameFree", async: false}
}
}
});
// this is for triggering the remote request only on blur by disabling onkeyup temporarily:
$('#username').on({
blur: function () {
},
focus: function () {
$(this).closest('form').validate().settings.onkeyup = false;
}
});
from jquery-validation.
I had the same exact issue and I commented that same line out and everything is good now. Thanks!
from jquery-validation.
I have also this issue when using the form() method. I had disabled all on-Events and then it seems obviously that a sync call like form() can never handle an async event like a remote validation.
from jquery-validation.
I stil can't reproduce this issue. @X-Coder provided the most detailed steps to reproduce, but he uses async: false
, which isn't supported and never will be.
I'm happy to look at reproducible issues, so if anyone else is (still) having this issue, please create a new ticket with a testpage and steps to reproduce.
from jquery-validation.
Related Issues (20)
- greaterThan() not normalizing input HOT 2
- Add ability to require at least one of multiple validation methods HOT 9
- Date validation failure. HOT 11
- Additional validation vinUS fails to validate valid Vehicle Identification Number (VIN).
- Add option to html escape the messages in showLabel function
- lessThan reports error if compared to empty field HOT 3
- Form not from HTML element HOT 2
- NuGet jQuery version dependency incorrect HOT 3
- Validation behaviour HOT 5
- If remote validation fails due to connection issue, it never allows the form to be submitted again HOT 1
- `step` automatic rule gets broken for very small steps HOT 2
- Validation error when remote check fields is preloaded. HOT 2
- I do not want this feature implemented on my device
- Form submitHandler endless loops HOT 2
- Focus on last focused field causes problems in accessibility HOT 1
- Cannot read properties of undefined (reading 'call'). Exception occurred when checking element , check the 'messages' method HOT 1
- Remote validation not working in last release HOT 4
- old version (19.5) on website HOT 1
- Using data-rule attributes for validation rules HOT 1
- file's accepted mimetypes as "*" results in a regex error
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from jquery-validation.