Mario
Mario

Reputation:

textboxes with value

I have page with 3 textbox. I to find all textboxes which have value into it and print its text. How to do?

Upvotes: 0

Views: 136

Answers (5)

Esteban Küber
Esteban Küber

Reputation: 36832

I gess that you need either

$("input[type=text]").val();

or

$("textarea").val();

Most likely, you will need both, so

$("input[type=text][value!=] textarea[value!=]").val();

would search the contents of all non empty elements on your page a user can insert text into.

Upvotes: 1

ranonE
ranonE

Reputation: 497

Use selector/text and selectors/attributeNotEqual.

$("form input:text[value!=]").each(function() {
  $(this).val();
});

Upvotes: 0

nickf
nickf

Reputation: 546045

$(':text').each(function() {
    alert(this.value);
});

Upvotes: 0

Keeper
Keeper

Reputation: 3566

This is the code to fetch all the values of the in a page which are not empty:

$('input[type=text][value!=]').each( function() { 
    var value = $(this).val();
    // do whatever you want with the value
});

Upvotes: 3

brettkelly
brettkelly

Reputation: 28205

$('input').each(function(){
    alert(this.value);
});

Upvotes: -1

Related Questions