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
Comments
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! |
I did #900, but I haven't gone back to fix and merge it yet |
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>.
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! |
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 thefor
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 onelabel
element perinput
due to screen reader issues), but brings up another one -<span for="form_field_id">Error message here</span>
is not valid HTML, as aspan
element can't have thefor
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 usedata-for
in cases where thefor
attribute isn't legal.The text was updated successfully, but these errors were encountered: