Created
September 20, 2013 13:13
-
-
Save jonesch/6637312 to your computer and use it in GitHub Desktop.
Generic JS Form validation
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
$('.general-contact-form').submit(function(){ | |
var req_values = ['user_name', 'user_email_address', 'user_phone_number', 'user_interest_in'], | |
empty_fields = false; | |
for (var i = 0; i < req_values.length; i++) { | |
if($('#'+req_values[i]).val() == ''){ | |
$('#'+req_values[i]).addClass('required'); | |
empty_fields = true; | |
} | |
} | |
if(empty_fields === true || ){ | |
log('you have some empty values'); | |
return false; | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment