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
Updated to jQuery Validation 1.11.1 and added aria-live region for reporting inline error message changes #1626
Conversation
pjackson28
commented
Mar 24, 2013
- Updated to jQuery Validation 1.11.1
- Fixed jQuery Validation 1.11.1 compatibility issues.
- Added bridge for supporting the old class={validate:{}} method.
- Updated form validation working examples to the new data-rule-* approach.
- Added aria-live region to report any changes in inline error messages.
… supporting the old class={validate:{}} method.
Updated to jQuery Validation 1.11.1 and added aria-live region for reporting inline error message changes
} | ||
} | ||
|
||
|
||
// Remove the pattern attribute until it is safe to use with jQuery Validation |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What is unsafe about the pattern rule?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It causes specific error messages to be replaced by generic invalid format messages.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wouldn't it be better to just add the translation strings to the i18n files rather than removing a rule?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think the location of the strings is the reason. It just seems to be triggering a generic invalid format error rather than a specific error.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"Invalid Format" is just the default error message https://github.com/jzaefferer/jquery-validation/blob/493c0c377242ad05b6b30e41af1ef9ed77bc70db/additional-methods.js#L502-L510
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's the problem, it is overriding the other more helpful error messages. For instance, if the input must be alpha-numeric and at least 4 characters, it says "Invalid format" rather than "Please enter at least 4 characters." or "Letters, numbers, and underscores only please". Keeping the pattern attribute on seems to quash all other possible error messages, even if they are more relevant. That is why Form validation is removing the pattern attribute for now (until this gets fixed in jQuery Validation).
The pattern attribute is still left on as an example for non-JS scenarios (assuming there is server-side handling).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Has a bug been filed upstream?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No it hasn't been. Didn't know what the source was until you pointed out the responsible lines. It wasn't a priority as validation was working without it.
PS: I have push access to jquery-validation now, is there any of the aria stuff we should push back? |
Here are some suggestions:
|
I didn't quite get the last bullet there but I started jquery-validation/jquery-validation#706 |
Thanks! The last bullet is about creating a container where you control the updates that get heard by screen readers. In the case of Form validation, it is only once the inline error message changes (and not for every refresh which may or may not have an error message change). |
Would that attribute be attached to the form element? |
No, it would just be a new div element (or other element) that gets appended to the form (and is invisible). It's sole purpose is to provide messages to screen readers by replacing the contents of the element each time. |
OK, can you update the issue with that info |