Thanks!!! That's exactly what I wanted =) Don't know if it's a bug, but with val entering some text in textarea with blank name field activated the button. With text() it stopped to do so. And, as I've read from some of the messages, text() could be more effective when dealing with textarea content.
dave.methvin wrote: > > >> $('#post_submit').attr('disabled', 'disabled'); >> $('#post_form').keyup( function () { >> if ($('#post_name', '#post_form').val() == '' && >> $('#post_content', >> '#post_form').text() == '') $('#post_submit').attr('disabled', >> 'disabled'); >> else ($('#post_submit', '#post_form').removeAttr('disabled')); >> }); > > I think this would work. The "disabled" attribute can be set to a true/ > false value in script. Since keyup can be an expensive thing, I just > attached handlers to the two fields you needed to monitor rather than > the whole form; you could attach it to the form if you prefer. Rather > than set the initial value, I just triggered the handler to do its > thing on the initial form values. I wasn't sure why you used .text() > instead of .val() for the textarea, is there some kind of bug > in .val() for textarea? Also, remember that any post content (even a > bunch of spaces) will pass this test. You might want to do a bit more > validation on the input if it's important to the page. > > $('#post_name, #post_content').keyup( function () { > $('#post_submit').attr('disabled', !$('#post_name').val() || !$ > ('#post_content').val() ); > }).trigger("keyup"); > > -- View this message in context: http://www.nabble.com/Disable-Submit-button-if-no-text-entered-tp17226575s27240p17237539.html Sent from the jQuery General Discussion mailing list archive at Nabble.com.