Get values after submit in jQuery

13,325

Solution 1

Try this on form submit:

alert($('#search').val());

where 'search' is id of the search input field.

Hope this might help!!

Solution 2

Assign your input with id="searched" // Any id you want..

then simply call

$('form').submit(function(){
    alert( $('#searched').val() );
});

Solution 3

It is very simple. You may get the value of the input filed like this:

var inputField = $('input[name]').val()
and just alert this.

alert(inputField);

Here you go.

Share:
13,325
user982853
Author by

user982853

Updated on June 04, 2022

Comments

  • user982853
    user982853 almost 2 years

    I have a form with just one field "search" and a submit button. My jQuery code looks like this:

    $( "form.qsearch" ).submit(function() {
     alert(inputsearchfield);
    })
    

    All I am trying to do is simply alert out the value in the search box. I have searched and search online and can't find anything for this simple code.

  • user982853
    user982853 over 9 years
    This simply returns the word "search" i need to return the value in the search box. Thank you.
  • Manoz
    Manoz over 9 years
    @user982853, Just place the value of searchbox inside alert. jsfiddle.net/vm8joatL