You can do this with jquery, for example,
Live demo
if($('#text_field').val() == "") $('#submitButtonId').attr('disabled', true); $('#text_field').keyup(function(){ if($('#text_field').val() != "") $('#submitButtonId').attr('disabled', false); else $('#submitButtonId').attr('disabled', true); });
For the latest version of jQuery, you may need to use prop () instead of attr () to set the disabled property of the element.
if($('#text_field').val() == "") $('#submitButtonId').prop('disabled', true);
Adil source share