Skip to content

Instantly share code, notes, and snippets.

@Archakov06
Last active November 16, 2016 10:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Archakov06/7f2855f4fc9eecf8727ef94297d48e02 to your computer and use it in GitHub Desktop.
Save Archakov06/7f2855f4fc9eecf8727ef94297d48e02 to your computer and use it in GitHub Desktop.
Check all required inputs
// if (!$('#fullname').val()) {
// $(this).addClass('error');
// return false;
// }
//
// if (!$('#email').val()) {
// $(this).addClass('error');
// return false;
// }
//
// if (!$('#text').val()) {
// $(this).addClass('error');
// return false;
// }
// All required fields
var fields = ['fullname','email','text'];
for (i in fields)
if (!$('#'+fields[i]).val()) {
$('#'+fields[i]).addClass('error');
return false;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment