CodeClerks

how to fetch the data from textbox in jQuery?



Write the reason you're deleting this FAQ

how to fetch the data from textbox in jQuery?

I have a textbox/textarea that looks like this:

<textarea name='data' id='data'></textarea>

The users type the data required and then I want to fetch that data using jQuery when they click the submit button. The data will be sent via AJAX to a PHP script for analysis (for spam, banned words, etc). How do I fetch the data from the textarea/textbox?

Comments

Please login or sign up to leave a comment

Join
robertman11
You can use the .val() function in jQuery to fetch the value. This will fetch the current value using your example:
$("#data").val()

Assign that value to a variable or pass it directly to the AJAX script you mentioned. You can also set the value of the textbox (IE: if the AJAX script reports spam) to be nothing or anything by entering a string in the .val():
$("#data").val("enter anything here");

 



Are you sure you want to delete this post?