how to get the value of all the input on submit in jquery code example
Example 1: jquery get all input name and values and submit
$("form").submit(function(){ return validateForm($(this)) });
function validateForm(form){
var retVal = true;
var re;
$.each(form.serializeArray(), function(i, field) {
var input = $('input[name='+field.name+']');
field.value = $.trim(field.value);
switch(field.name){
case "name" :
and another cases...
}
})
}
Example 2: jquery get value of input submit
$("#submit_button").click(function() {
var data = $("#my_form").serialize();
data += data.length ? "&" : "";
data += escape($(this).attr("name"))+"="+escape($(this).val());
return false;
});