Enable Disable Submit Button on Textarea Using jQuery | Code Snippet

1 Feb , 2013  Code Snippets 

Enable-Disable-Textarea-Submit-ButtonCode Snippet #1: The code we found today is to enable or disable the submit button for Textarea using jQuery script. Textarea or Textbox validation using jQuery to find if any data is entered, based on this the submit button is either stays disabled or enabled.

In one of our previous tutorial, we had seen form validation for special characters using JavaScript. This is a brand new code snippet again based on validation.

DEMO:[See Real time enabling of the submit button as you start typing]

The Code Snippet:

HTML:

jQuery:

Here in the above code, we see that the textarea tag is used to specify a textarea where users can enter some text/data. We give the textarea an id “text-area”. Along with the textarea we also specify a submit button.

Now, in the jQuery part we bind the textarea bearing the ID “text-area” with an event “keyup” and ask it to validate the data. Keyup function is an event in jQuery which allows us to check the event generated by the release of keyboard keys.

When the validateForm is called, it validates if the textarea has any string entered by the user, if entered then add the enabled attribute to input submit button by the code:

Else use the below code and make it disabled:

That’s for today. This is just a touch point for starting something similar for your project to enable disable submit button using jQuery. You can enhance the code to make it more robust.



, ,

  • Seong Lee

    That was helpful, thanks.