tags:

views:

25265

answers:

6

I can get the element like this $("txtEmail") but I'm not sure how to get the actual value.

Update

If .val() is the answer, can you give me the context on how to use it?

Thanks!

+17  A: 

Use the .val() method.

Also I think you meant to use $("#txtEmail") as $("txtEmail") returns elements of type <txtEmail> which you probably don't have.

See here at the jQuery documentation.

Also jQuery val() method.

Spencer Ruport
+1 for me making the exact same mistake
Kevin Laity
+44  A: 

I think there's a .val() method

Edit:

If you've got an input with an id of txtEmail you should be able to use the following code to access the value of the text box:

$("#txtEmail").val()

You can also use the val(string) method to set that value:

$("#txtEmail").val("something")

Hope that helps!

UltimatePace
A: 

JQuery is a great tool, I'm using it right now, but what does using it for value extraction instead of the DOM buy you?

for one thing, full cross browser functionality.
adam
I'm not sure I understand the question. Basically I want to get the value from the textbox and validate the email address. I'm still new to jquery, so now I'm searching for a validation plugin.
Micah
Convenience methods, cross browser support. It's still Javascript underneath, but it takes a lot of the headaches out.
micmcg
+2  A: 

Noticed your comment about using it for email validation and needing a plugin, the validation plugin may help you, its located at http://bassistance.de/jquery-plugins/jquery-plugin-validation/, it comes with a e-mail rule as well.

Wardy
A: 

all of avove are wrong.

pawan damase
How's that ?The question is how to get the value of a textbox by JQuery, and the top reply is the best way of doing so; certainly at time of asking.
Russ C
A: 

I do not know how to retrieve value from text box .its really help full to me.Thanks a lot.

Alok Das