Created
April 18, 2019 16:24
-
-
Save mohshbool/8afc7ab0427ffb0c12ba35da57f1ebb8 to your computer and use it in GitHub Desktop.
Validate form function using jQuery@^3.x
This file contains hidden or 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 validateForm = () => { | |
$('input').each(function() { | |
const $this = $(this); | |
const $button = $('button'); | |
if ($this.val() === '' || $this.val().length <= 0) { | |
$button.attr('disabled', 'disabled'); | |
} else if (!$button.attr('disabled')) { | |
$button.removeAttr('disabled'); | |
} | |
}) | |
} | |
$('input').on('input', validateForm); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment