-4

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ñaki
  • 89
  • 1
  • 10

3 Answers3

1

using jquery

var n=$('#textarea_id').val();

using javascript

var n=document.getElementById('textAreaID').value;
Deepu Reghunath
  • 6,468
  • 1
  • 30
  • 41
0

Use following code

var textareaValue = document.getElementById('textAreadID').value

Replace textAreadID with your textarea id.

Vipin Kumar
  • 6,243
  • 1
  • 17
  • 25
0

In jQuery:

var str = "compare with me",
value = $('textarea[name="yourareaname"]').val();

if(str == value) {
    alert('hell yeah');
}
Brainfeeder
  • 2,497
  • 2
  • 18
  • 35