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

Allow the attribute used to find error elements to be specified #966

Closed
madmatt opened this issue Jan 7, 2014 · 3 comments
Closed

Allow the attribute used to find error elements to be specified #966

madmatt opened this issue Jan 7, 2014 · 3 comments

Comments

@madmatt
Copy link

madmatt commented Jan 7, 2014

To properly use the errorElement setting, you generally also need to change the attribute that validation uses to determine whether an error message exists already. By default, the plugin uses the label element, and the for attribute. For example: <label for="form_field_id">Your error message here</label>

Changing the errorElement to span for example fixes one accessibility issue (that you can't have more than one label element per input due to screen reader issues), but brings up another one - <span for="form_field_id">Error message here</span> is not valid HTML, as a span element can't have the for attribute.

Therefore, we need a way of also specifying which attribute of the element to check, instead of hard-coding the for attribute. Then, we could use data-for in cases where the for attribute isn't legal.

@madmatt
Copy link
Author

madmatt commented Jan 7, 2014

At a brief glance, this should be relatively easy to fix (two one-line code changes and a new addition to this.settings), I'll try and get a PR through for this if it makes sense to others as well as me!

@nschonni
Copy link
Collaborator

nschonni commented Jan 7, 2014

I did #900, but I haven't gone back to fix and merge it yet

madmatt added a commit to madmatt/jquery-validation that referenced this issue Jan 7, 2014
Adds an `errorAttribute` setting that complements the existing `errorElement`
setting. You can use these together to create an error element like
<span data-for="form_field_id">Your error message here.</span>.
@jzaefferer
Copy link
Collaborator

I'm sorry for the lack of activity on this issue. Instead of leaving it open any longer, I decided to close old issues without trying to address them, to longer give the false impression that it will get addressed eventually, especially after several years with no activity. It doesn't mean I'm abandoning the project, just that I'm unable to work through 200+ open issues with the little time I can afford to spend on this project.

To the reporter (or anyone else interested in this issue): If you're still affected by the same issue, please consider opening a new issue, with a testpage that demonstrates the issue with a current version of the plugin. Even better, make an attempt to fix the issue yourself, and improve the project by sending a pull request. This may seem daunting at first, but you'll likely learn some useful skills that you can apply elsewhere as well. And you can help keep this project alive. We've documented how to do these things, too. A patch is worth a thousand issues!

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

3 participants