I want to store the text users enter into a textarea in a website into a javascript variable in order to compare it to another variable already defined.
How would you do it? Any hints? Thanks in advance!
I want to store the text users enter into a textarea in a website into a javascript variable in order to compare it to another variable already defined.
How would you do it? Any hints? Thanks in advance!
using jquery
var n=$('#textarea_id').val();
using javascript
var n=document.getElementById('textAreaID').value;
Use following code
var textareaValue = document.getElementById('textAreadID').value
Replace textAreadID
with your textarea
id
.
In jQuery:
var str = "compare with me",
value = $('textarea[name="yourareaname"]').val();
if(str == value) {
alert('hell yeah');
}