title: Show error message on the same pop up window where form is created
body: <p>I have made a form that is displaying in pop up window now I want to validate that form in such a way that error message should display on the same pop up where form is created and also I want to stop the submit event if <strong>Error Array contain some errors</strong> this is the code I have used so far.</p>
  
  <pre><code>&lt;!-- Modal --&gt;
  &lt;div id="myModal" class="modal fade" role="dialog"&gt;
      &lt;div class="modal-dialog"&gt;
          &lt;!-- Modal content--&gt;
          &lt;div class="modal-content"&gt;
              &lt;div class="modal-header"&gt;
                  &lt;button type="button" class="close" data-dismiss="modal"&gt;&amp;times;&lt;/button&gt;
                  &lt;h4 class="modal-title"&gt;&lt;?php the_title(); ?&gt;&lt;/h4&gt;
              &lt;/div&gt;
              &lt;div class="modal-body"&gt;
                  &lt;p style="font-size: 18px; font-weight: normal; font-family: inherit;"&gt;
                      After clicking claim this item will be reserved for you and you will 
                      receive an invoice from &lt;?php echo get_the_author(); ?&gt; with 
                      instructions for completing payment.
                  &lt;/p&gt;
  
  
                  &lt;?php 
                      if($errArray != '') {
                          foreach ($errArray as $error) {
                  ?&gt;
                      &lt;div class="btn btn-danger"&gt;
                          &lt;ul&gt;
                          &lt;?php
                              if($error != '') {
                          ?&gt;
  
                              &lt;li&gt;&lt;?php echo $error; ?&gt;&lt;/li&gt;
  
                          &lt;?php } ?&gt;
                          &lt;/ul&gt;
                      &lt;/div&gt;
                  &lt;?php
                          }
                      }
                  ?&gt;
  
                  &lt;form class="form-horizontal" action="#" method="POST"&gt;
  
                      &lt;div class="form-group" style="margin: 10px; padding: 0px;"&gt;
                          &lt;lable class=" col-md-5 control-label h4"&gt;Name *&lt;/lable&gt;
                          &lt;div class="col-md-6"&gt;
                              &lt;input type="text" name="name" id="name" placeholder="Enter your Name" class="form-control" required /&gt;
                          &lt;/div&gt;
                      &lt;/div&gt;
  
                      &lt;div class="form-group" style="margin: 10px; padding: 0px;"&gt;
                          &lt;lable class="control-label col-md-5 h4"&gt;Email *&lt;/lable&gt;
                          &lt;div class="col-md-6"&gt;
                              &lt;input type="email" name="email" id="email" placeholder="Enter your Email" class="form-control" required/&gt;
                          &lt;/div&gt;
                      &lt;/div&gt;
  
  
                      &lt;div class="form-group" style="margin: 10px; padding: 0px;"&gt;
                          &lt;lable class="control-label col-md-5 h4"&gt;Shipping Address *&lt;/lable&gt;
                          &lt;div class="col-md-6"&gt;
                              &lt;input type="text" name="shipping_address" id="ship_add" placeholder="Enter your Shipping Address" class="form-control" required/&gt;
                          &lt;/div&gt;
                      &lt;/div&gt;
  
                      &lt;div class="form-group" style="margin: 10px; padding: 0px;"&gt;
                          &lt;lable class="control-label col-md-5 h4"&gt;City *&lt;/lable&gt;
                          &lt;div class="col-md-6"&gt;
                              &lt;input type="text" name="city" id="city" placeholder="Enter your City" class="form-control" required/&gt;
                          &lt;/div&gt;
                      &lt;/div&gt;
  
                      &lt;div class="form-group" style="margin: 10px; padding: 0px;"&gt;
                          &lt;lable class="control-label col-md-5 h4"&gt;State *&lt;/lable&gt;
                          &lt;div class="col-md-6"&gt;
                              &lt;input type="text" name="state" id="state" placeholder="Enter your State" class="form-control" required/&gt;
                          &lt;/div&gt;
                      &lt;/div&gt;
  
                      &lt;div class="form-group" style="margin: 10px; padding: 0px;"&gt;
                          &lt;lable class="control-label col-md-5 h4"&gt;Zip *&lt;/lable&gt;
                          &lt;div class="col-md-6"&gt;
                              &lt;input type="text" name="zip" id="zip" placeholder="Enter your Zip Code" class="form-control" required/&gt;
                          &lt;/div&gt;
                      &lt;/div&gt;
  
                      &lt;div class="form-group" style="margin: 10px; padding: 0px;"&gt;
                          &lt;lable class="control-label col-md-5 h4"&gt;Phone *&lt;/lable&gt;
                          &lt;div class="col-md-6"&gt;
                              &lt;input type="text" name="phone" id="phone" placeholder="Enter your Phone Number" class="form-control" required/&gt;
                          &lt;/div&gt;
                      &lt;/div&gt;
  
                      &lt;div class="form-group" style="margin: 10px; padding: 0px;"&gt;
                          &lt;lable class="control-label col-md-5 h4"&gt;Notes&lt;/lable&gt;
                          &lt;div class="col-md-6"&gt;
                              &lt;input type="text" id="notes" name="notes" class="form-control"/&gt;
                          &lt;/div&gt;
                      &lt;/div&gt;
  
                      &lt;div class="col-md-12"&gt;
                          &lt;div&gt;
                              &lt;button type="button" class="btn btn-default pull-right" data-dismiss="modal"&gt;Close&lt;/button&gt;
                          &lt;/div&gt;
                          &lt;div&gt;
                              &lt;input type="submit" value="Claim" class="btn btn-primary pull-right" style="margin-right: 2%;"/&gt;
                          &lt;/div&gt;
                      &lt;/div&gt;
                  &lt;/form&gt;
              &lt;/div&gt;
              &lt;div style="clear: both;"&gt;&lt;/div&gt;
              &lt;div class="modal-footer"&gt;
              &lt;/div&gt;
          &lt;/div&gt;
      &lt;/div&gt;
  &lt;/div&gt;
  
  &lt;?php
  if (!empty($_POST)) {
      $product_id = get_the_ID();
      $name = esc_attr($_POST['name']);
      $email = esc_attr($_POST['email']);
      $s_address = esc_attr($_POST['shipping_address']);
      $city = esc_attr($_POST['city']);
      $state = esc_attr($_POST['state']);
      $zip = esc_attr($_POST['zip']);
      $phone = esc_attr($_POST['phone']);
      $notes = esc_attr($_POST['notes']);
  
      $errArray = [];
      if(empty($name)) {
          echo "Name is required";
          array_push($errArray, 'Name is requried');
      }
      if(empty($email)){
          array_push($errArray, 'Email is required');
      }
      if(empty($s_address)){
          array_push($errArray, 'Shipping Address is required');   
      }
      if(empty($city)){
          array_push($errArray, 'City is required');
      }
      if(empty($state)) {
          array_push($errArray, 'State is required');
      }
      if(empty($zip)) {
          array_push($errArray, 'Post Code is required');
      }
      if(empty($phone)){
          array_push($errArray, 'Phone is required');
      }
  
      if(empty($errArray)){
          global $woocommerce;
            $address = array(
                'first_name' =&gt; $name,
                'email'      =&gt; $email,
                'phone'      =&gt; $phone,
                'address_1'  =&gt; $s_address,
                'city'       =&gt; $city,
                'state'      =&gt; $state,
                'postcode'   =&gt; $zip,
            );
            // Now we create the order
            $order = wc_create_order();
            // The add_product() function below is located in /plugins/woocommerce/includes/abstracts/abstract_wc_order.php
            $order-&gt;add_product( get_product($product_id), 1 ); // This is an existing SIMPLE product
            $order-&gt;set_address( $address, 'billing' );
            //
            $order-&gt;calculate_totals();
            $order-&gt;update_status("wc-new", 'Imported order', TRUE);
  
  
  
          global $wpdb;
  
          $table = wp_store_claims;
          $data = array(
              'product_id' =&gt; $product_id,
              'name' =&gt; $name,
              'email' =&gt; $email,
              's_address' =&gt; $s_address,
              'city' =&gt; $city,
              'state' =&gt; $state,
              'zip' =&gt; $zip,
              'notes' =&gt; $notes,
              'phone' =&gt; $phone,
          );
  
          $success = $wpdb-&gt;insert($table, $data);
      } else {
          return false;
      }
    }
  </code></pre>
  
  <p>I am stuck here anyone here who can help me out would be great. Thank you in advance</p>