Can you tell me how can I get all <input>
fields with custom "validation" attribute.
<form>
<p><input type="text" id="first_name" name="first_name" validation="isRequired,currectFormat" placeholder="first name" required/></p>
<p><input type="text" id="last_name" name="last_name" validation="isRequired,currectFormat" placeholder="last name"/></p>
<p><input type="text" id="email" name="email" validation="isRequired,currectFormat" placeholder="email"/></p>
<p><input type="text" id="address" name="address" placeholder="address" /></p>
<input type="button" value="OK">
</form>
var inputs = document.querySelectorAll('form input[validation]');
use css attribute selectors in querySelectorAll()
.
您是否尝试过执行以下操作:
document.querySelectorAll('input[validation="isRequired,currentFormat"]');
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.