Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Display form values prior to submit for debugging

How can I dump all of my form values to an alert box prior to form submit..

I have a simple form like this.. I'd like to see the form values in an alert or console at the time of submit.. I'm using jQuery and jQueryUI (DIALOG) for the form.. but any approach is fin -

<div id="highValueSurvey" title="Some More Advanced Questions">
        <p class="validateTips">All form fields are required.</p>
        <form>
        <fieldset>
            <label for="name">Name</label>
            <input type="text" name="name" id="name" value=""/>
            <BR>
            <label for="email">Email</label>
            <input type="text" name="email" id="email" value=""/>
            <BR>        
            <label for="name">Tell us More</label>
            <input type="text" name="more" id="more"/>
            <BR>
            <BR>        
            <label for="name">We want to know even more!!!!</label>
            <input type="textarea" name="evenmore" id="evenmore"/>
            <BR>
        </fieldset>
        </form>
    </div>
like image 356
patrick Avatar asked Oct 05 '11 20:10

patrick


2 Answers

You have a very good example right here: http://api.jquery.com/serialize/

$('form').submit(function() {
  alert($(this).serialize());
  return false;
});
like image 141
David Hellsing Avatar answered Nov 09 '22 04:11

David Hellsing


console.info($('#highValueSurvey form').serializeArray())

.serializeArray()

like image 39
Einacio Avatar answered Nov 09 '22 05:11

Einacio