Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Show form data in console on submit

Is it possible to show all the form data in console when the form is submitted and then the data is posted to the server as well?

Something like that?

<form action="http://whatever.com" method="POST" onSubmit="console.log(All Form Data)">

Thanks Ahmar.

like image 330
Ahmar Ali Avatar asked Oct 02 '22 01:10

Ahmar Ali


1 Answers

Try

$(function() {
  $('form').submit(function() {
    console.log('Input 1: '+$('input[name="input1"]').val() + ' Input 2: '+ $('input[name="input2"]').val()); // etc.
  });
});

or give Id's to inputs then

<form onSubmit="console.log('Input 1: '+document.getElementById('input1').value + ' Input 2: '+document.getElementById('input2').value)">
like image 143
mdesdev Avatar answered Oct 13 '22 10:10

mdesdev