我正在使用jQuery Validation Unobtrusive的最新版本與最新版本的jQuery Validate結合使用。驗證本身就像一個魅力。但是,如果該字段無效,則值將被添加到aria-describedby
屬性中。使用jQuery驗證時使用jQuery驗證的多個值不顯眼
比方說,我想輸入我的密碼(驗證密碼的長度必須大於6)。最初的HTML是這樣的:
<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">
我開始鍵入只有5個字符的密碼,然後通過點擊body
某處移除焦點從input
。驗證會通過,並會添加一些屬性和值,包括aria-describedby
。現在aria-describedby
屬性只有一個值Password-error
。如果我然後再次對輸入字段進行聚焦並刪除所有字符,甚至保持按下退格鍵,則會添加每個鍵盤上的新值。這導致以下結果:
<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">
這是一個相當值的開銷值的屬性considiering值是相等的。這是行爲通常還是有人知道如何解決這個問題?
您是否找到任何解決方案? – Alex 2015-10-10 04:14:46
請參閱下面的答案。不知何故,我重建了VS中的解決方案後,問題消失了,並刪除了在後臺創建的影子副本。 – LordTribual 2015-10-11 06:53:16