?
Referenced as Pull Request for: # 6613
avatar vinespie
vinespie
27 Mar 2015

Client-side form validation : aria-invalid on label

Hello,

When using the client-side form validation system joomla " behavior.formvalidator " when a field is misinformed and when the field is linked to a label, the attribute " aria -invalid = true" is added to the label.
According to accessibility standards this attribute should be only placed on the attribute "input".

Thank you for your answers

http://www.w3.org/TR/wai-aria/states_and_properties#aria-invalid
https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/ARIA_Techniques/Using_the_aria-invalid_attribute

Example before client-side validation :

<form  class="form-validate" method="post">
     <label id="jform_title-lbl" title="" for="jform_title">Title</label>
     <input id="jform_title" type="text" aria-required="true" required="required">
</form>

Example after client-side validation wrong :

<form  class="form-validate" method="post">
     <label id="jform_title-lbl" title="" for="jform_title" aria-invalid="true">Title</label>
     <input id="jform_title" type="text" aria-required="true" required="required" aria-invalid="true">
</form>

Example after client-side validation correct:

<form  class="form-validate" method="post">
     <label id="jform_title-lbl" title="" for="jform_title">Title</label>
     <input id="jform_title" type="text" aria-required="true" required="required" aria-invalid="true">
</form>

Patch to \media\system\js\validate-uncompressed.js

Remove line 52

if($label){
     $label.addClass('invalid');
}

Remove line 57

if($label){
     $label.removeClass('invalid');
}
avatar vinespie vinespie - open - 27 Mar 2015
avatar joomla-cms-bot joomla-cms-bot - change - 27 Mar 2015
Labels Added: ?
avatar zero-24 zero-24 - change - 27 Mar 2015
Category JavaScript
avatar bertmert
bertmert - comment - 28 Mar 2015

If you're right (I don't know but think so after reading also https://www.w3.org/WAI/GL/wiki/Using_Aria-Invalid_to_Indicate_An_Error_Field#Example_1)

your patch should be

Change line 52

if($label){
     $label.addClass('invalid');
}

Change line 57

if($label){
     $label.removeClass('invalid');
}
avatar vinespie
vinespie - comment - 28 Mar 2015

Yes @bertmert , leave the class "invalid" just delete "aria- invalid"

avatar vinespie vinespie - change - 30 Mar 2015
The description was changed
avatar zero-24
zero-24 - comment - 30 Mar 2015

Closing and copy the description as we have a PR (#6613) thanks!

avatar zero-24 zero-24 - change - 30 Mar 2015
Status New Closed
Closed_Date 0000-00-00 00:00:00 2015-03-30 21:35:00
avatar zero-24 zero-24 - close - 30 Mar 2015

Add a Comment

Login with GitHub to post a comment