Last active
January 4, 2017 06:42
-
-
Save eddiemoore/00f56137dfd705269670b1da68a721dd to your computer and use it in GitHub Desktop.
Simple function to check if all required fields are filled out correctly
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const isFormValid = form => { | |
const elements = form && form.elements | |
if (!elements) return false | |
return Array.from(elements).every(elem => elem.validity && elem.validity.valid) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
@eddiemoore Throws when
form
is undefined but otherwise similar behaviour in thefor
/of
style.