admin管理员组

文章数量:1417408

How can you check the value of aria-invalid in an input form?

Here's my input field and the value of aria-invalid is false:

<input type="email" name="your-email" value="" size="40" class="wpcf7-form-control wpcf7-text wpcf7-email wpcf7-validates-as-required wpcf7-validates-as-email" id="contact-email" aria-required="true" aria-invalid="false" placeholder="Email *">

I need to identify the aria-invalid if it's true or false. Here's my javascript for identifying this and I'm having a difficulty

<script>
$(document).ready(function(){
    var input_email = document.getElementById("contact-email");

});

Help with this please thanks!

How can you check the value of aria-invalid in an input form?

Here's my input field and the value of aria-invalid is false:

<input type="email" name="your-email" value="" size="40" class="wpcf7-form-control wpcf7-text wpcf7-email wpcf7-validates-as-required wpcf7-validates-as-email" id="contact-email" aria-required="true" aria-invalid="false" placeholder="Email *">

I need to identify the aria-invalid if it's true or false. Here's my javascript for identifying this and I'm having a difficulty

<script>
$(document).ready(function(){
    var input_email = document.getElementById("contact-email");

});

Help with this please thanks!

Share Improve this question asked May 16, 2018 at 1:03 Jae EunJae Eun 573 silver badges15 bronze badges
Add a ment  | 

1 Answer 1

Reset to default 4

Use getAttribute() to get the value of attributes, in your case aria-invalid

document.getElementById("contact-email").getAttribute("aria-invalid")

本文标签: javascriptHow to check AriaInvalid in an Input FormStack Overflow