I want to use the required
attribute on one of my input fields. I have already coded in the JS version of it, but for completeness' sake, why not include the HTML 5 as well (at the very least save trouble for non JS users).
Is it safe to just add required
to the input, it does it not degrade gracefully? If it doesn't, then how can I check for its support (without Modernizr)?
If you're using
<!DOCTYPE html>
then there's no problem adding therequired
attribute.You can feature detect using this JS: