Refresh form on click of cancel button

<form method="post" id="sample_form" class="form-horizontal" enctype="multipart/form-data">
                   @csrf

                   <div class="form-group">
                       <label class="control-label col-md-3"> Phone<big class="text-danger">*</big></label>
                       <div class="col-md-8">
                           <input type="text" value="" class="form-control" id="phone" name="phone" placeholder="Enter Full Phone No" required>
                           <div id="visitorList"></div>
                       </div>
                   </div>

                       <div class="form-group">
                           <label class="control-label col-md-3" >Name<big class="text-danger">*</big></label>
                           <div class="col-md-8">
                               <input type="text" value="" name="name" id="name" class="form-control" placeholder="Enter Visitor Name"  required/>
                           </div>
                       </div>


                   <div class="form-group">
                       <label class="control-label col-md-3">Email<big class="text-danger">*</big></label>
                       <div class="col-md-8">
                           <input type="email" value="" class="form-control" id="email" name="email" placeholder="Enter Visitor Email" required>
                       </div>
                   </div>



                   <div class="form-group">
                       <label class="control-label col-md-3"> Company<big class="text-success"></big></label>
                       <div class="col-md-8">
                           <input type="text" class="form-control" id="company" name="company" placeholder="Enter Company Name">
                       </div>
                   </div>

                   <div class="form-group">
                       <label class="control-label col-md-3"> C.Address<big class="text-success"></big></label>
                       <div class="col-md-8">
                    <input type="text" class="form-control" id="address" name="address" placeholder="Enter Company Email">
                       </div>
                   </div>



         <div class="form-group" align="center">
             <input type="hidden" name="action" id="action" />
            <input type="hidden" name="hidden_id" id="hidden_id" />
            <input type="submit" name="action_button" id="action_button" class="btn btn-success" value="Add" />
                   </div>
               </form>
    
   
<script>
$("#cancel").click(function () {
   $('#sample_form')[0].reset();
   $("#name").val("");
   $("#phone").val("");
   $("#results").html("");
   $("#email").val("");
   $("#company").val("");
   $("#address").val("");
});
<script>

0 Comments:

Post a Comment

Share

Twitter Delicious Facebook Digg Stumbleupon Favorites More