Alex Barber | Digital Artist

time to push the pixels

jQuery detect input fields are blank

Used this one to check if all hidden fields in a form were blank, and prevent form submit if they were.

https://stackoverflow.com/questions/5599504/jquery-detect-input-fields-are-blank


// check if hidden fields are all blank
var allBlank = true;
$('input.searchhidden').each(function() {
return allBlank = allBlank && !$(this).val();
});

if ( allBlank ) {
console.log('empty');
e.preventDefault();
}

Next Post

Previous Post

Leave a Reply

© 2024 Alex Barber | Digital Artist