简体   繁体   中英

Multiple values for aria-describedby when using jQuery Validation Unobtrusive

I am using the latest version of jQuery Validation Unobtrusive in combination with the latest version of jQuery Validate. The validation itself works like a charm. However if the field is invalid, values will be added to the aria-describedby attribute.

Let's say I want to type in my password (for validation the length of the password must be greater than 6). The initial HTML looks like this:

<input data-val="true" data-val-minlength="The field Passwort must be a string or array type with      a minimum length of '6'." 
   data-val-minlength-min="6" data-val-required="The Passwort field is required." 
   id="Password" name="Password" tabindex="2" 
type="password">

I start to type a password with only 5 characters and then remove focus from the input by clicking somewhere on the body . The validation runs through and a bunch of attributes and values including aria-describedby will be added. Now the aria-describedby attribute only has a single value Password-error . If I then focus the input field again and remove all characters and even keep pressing backspace, a new value on each keyup is added. This results in the following:

<input data-val="true" 
   data-val-minlength="The field Passwort must be a string or array type with a minimum length of '6'." 
   data-val-minlength-min="6" 
   data-val-required="The Passwort field is required." 
   id="Password" name="Password" tabindex="2" type="password" aria-required="true" 
   aria-invalid="true" class="input-validation-error" 
   aria-describedby="Password-error Password-error Password-error Password-error Password-error Password-error Password-error Password-error Password-error Password-error Password-error Password-error Password-error Password-error Password-error Password-error Password-error Password-error Password-error Password-error Password-error Password-error Password-error 
Password-error">

This is quite an overhead of values for the attribute considiering that the values are equal. Is this behaviour usual or does someone know how to fix this?

此问题出现在jquery.validate.js的v1.13.0中,但此后已得到修复(至少在v1.14.0中)。

我对此问题没有明确的解释,但由于Visual Studio在后台创建了卷影副本,我可以通过清除cashe并删除项目的所有阴影文件并在之后重建来解决问题。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM