Skip to content

Instantly share code, notes, and snippets.

@pixelcoder
Created July 21, 2017 19:04
Show Gist options
  • Save pixelcoder/2f5d76262a6f154895dafc75be8eaf41 to your computer and use it in GitHub Desktop.
Save pixelcoder/2f5d76262a6f154895dafc75be8eaf41 to your computer and use it in GitHub Desktop.
Tidy up GET requests with jQuery
$('form').on('submit', function(e) {
$.each($('select'), function(i, v) {
$.each($('select option:selected'), function(i, v) {
if($(this).val() === ''){
$(this).parent('select').prop('disabled', true);
}
});
});
$.each($('input'), function(i, v) {
if($(this).val() === ''){
$(this).prop('disabled', true);
}
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment