0

I have a form and I just want a simple jquery message box that displays all the users input before submission and confirming to submit. I'm new to jquery. Any help is highly appreciated. Thanks. Here's my form.

       <form role="form" id="form-field" action="inc/Controller/OperatorController.php" method="post"  enctype="multipart/form-data" onsubmit="return validateForm();">

              <div class="form-group">
              <label>Last Name</label><span class="label label-danger">*required</span>
              <input class="form-control" placeholder="Enter Last Name" name="lastname" id="lastname">
            </div>

            <div class="form-group">
              <label>First Name</label><span class="label label-danger">*required</span>
              <input class="form-control" placeholder="Enter First Name" name="firstname" id="firstname">
            </div>

            <div class="form-group">
              <label>Address</label>
            </div>

            <input type="submit" name="btn" value="Submit" id="submit" class="btn btn-default"/>
            <input type="button" name="btn" value="Reset" onclick="window.location='fillup.php'" class="btn btn-default"/>
      </form>
jackhammer013
  • 2,295
  • 11
  • 45
  • 95
  • You haven't posted any javascript. Is your jquery not working, or are you asking how to use form validation? – Joe May 20 '14 at 01:57

1 Answers1

0

http://codepen.io/anon/pen/Imkhy

This code snippet loops through your form collecting the html of the labels and the value of the inputs. It puts that into a string and asks to confirm while the window is displaying the data the script collected.

If confirmed, the forms submits, if not, the form submission is prevented allowing the user to edit the content.

I added the for attribute to your <label> elements. Never forget to add the for attribute! for links the label to your input, and it makes things easier for the dev and the user.

Palmer
  • 173
  • 9