MJ
asked on
Detecting Value of Generic Custom Attribute Without Adding Code Directly to Element?
I'm trying to figure out, using Javascript, how to detect the value of an email input by using the last attribute "aria-invalid" (will equal "true" or "false"). The issue is other fields on the page use the same attribute "aria-invalid" in the same fashion. Not sure how I can read the value of the email input attribute only? I can NOT add any code to the element and NO jQuery please.
Thanks!
<input class="masked-zip-code not-empty input-validation-error" data-val="true" data-val-regex="Enter a valid (5-digit) ZIP code." data-val-regex-pattern="^\d{5}(-\d{4})?$" data-val-required="Enter a ZIP code" id="ZipCode" name="ZipCode" type="text" value="" aria-required="true" aria-describedby="ZipCode-error" aria-invalid="true">
Thanks!
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
HI JUlian,
NO jQuery because this will be part of a DTM rule which gets deployed to multiple third-party solutions which may not have jQuery?
NO jQuery because this will be part of a DTM rule which gets deployed to multiple third-party solutions which may not have jQuery?
ASKER
Found answer on my own
The accepted answer does not answer the question.
No email field and nothing to say this is the last field with aria-invalid attribute.
Cannot see how the accepted solution asks the question asked.
I'm trying to figure out, using Javascript, how to detect the value of an email input by using the last attribute "aria-invalid"The solution uses an id of ZipCode on the element to find the attribute - but this has no bearing on the question.
No email field and nothing to say this is the last field with aria-invalid attribute.
Cannot see how the accepted solution asks the question asked.
You can do it like this if you are not worried about older versions of IE
Open in new window