javascript - Checking if input values are empty -


i'm trying create tool allows users generate css code. @ moment i'm working on input - when user leaves text input empty, i'd message appear. code have @ moment doesn't seem work in doing so, ideas?

$("#btn-css").click(function() {     if( $('input').attr(value) = "" ) {       $('#output').append('all boxes must completed');     } else {       $('.preview').attr('style', 'box-shadow: ' + $("#h-value").val() + 'px ' + $("#v-value").val() + 'px ' + $("#blur").val() + 'px ' + $("#spread").val() + 'px #' + $("#colour").val() + ';');       $('#output').append('box-shadow: ' + $("#h-value").val() + 'px ' + $("#v-value").val() + 'px ' + $("#blur").val() + 'px ' + $("#spread").val() + 'px #' + $("#colour").val() + ';');     }     }); 

how select text inputs on page filter them ones empty.

$("#btn-css").click(function() {     var emptyinputs = $('input:text').filter(function() { return this.value == ""; });     if (emptyinputs.length === 0) {         // filled in      } else {         $('#output').append('all boxes must completed');     }  }); 

you might want do:

var emptyinputs = $('input:text').filter(function() { return $.trim(this.value) == ""; }); 

this pick text inputs whitespace.


Comments

Popular posts from this blog

javascript - DIV "hiding" when changing dropdown value -

Does Firefox offer AppleScript support to get URL of windows? -

android - How to install packaged app on Firefox for mobile? -