 <?php error_reporting(E_ALL);
ini_set('display_errors', 1);?>
 <form class="contact-form"  method="POST" id="myForm"  enctype="multipart/form-data">
                           	       <div id"check1"></div>
                              <div class="row">
                                 <div class="col-md-12">
                                    <div class="contact-form-section">
                                       <input type="text" class="form-control" placeholder="Your Name *" name="name" id="name">
                                    </div>                                      
                                 </div>
                                 <div class="col-md-12">
                                    <div class="contact-form-section">
                                       <input type="text" class="form-control" placeholder="Your Phone No. *" name="number" id="number">
                                    </div>                                      
                                 </div>
                                 <div class="col-md-12">
                                    <div class="contact-form-section">
                                       <input type="email" class="form-control" placeholder="Your Email *" name="email" id="email"> 
                                    </div>                                  
                                 </div>
                                 <div class="col-md-12">
                                    <div class="contact-form-section">
                                       <select class="form-select" aria-label="Default select example" name="doctor" id="doctor">
                                          <option selected="">Select Your Departments</option>
                                          <option value="1">Cardiology</option>
                                          <option value="2">Medicine</option>
                                          <option value="3">Gynec Laproscopy</option>
                                          <option value="4">Orthopedic</option>
                                          <option value="5">Pediatrics</option>
                                          <option value="6">Hip And Knee Joint Replacement</option>
                                          <option value="7">General Surgery</option>
                                          <option value="8">Neurology</option>
                                          <option value="9">Onchology</option>
                                          <option value="10">Plastic Surgery</option>
                                          <option value="11">ENT</option>
                                          <option value="12">Urology</option>
                                          <option value="13">Radiology</option>
                                          <option value="14">Ophthalmology</option>
                                          <option value="15">Dialysis</option>
                                       </select> 
                                    </div>                         
                                 </div>
                                 <div class="col-md-12">
                                    <div class="contact-form-section">
                                       <textarea class="form-control" name="message" id="message"  rows="4" placeholder="Comment" style="height: 100px;"></textarea>
                                    </div>
                                 </div>
                                 <div class="col-md-12">
                                    <div class="contact-form-section mb-5">
                                        <!--<input type="submit"  id="btn_submit" value="Submit" class="form-control">-->
                            <!--	<button type="submit" name="submit" id="btn_submit" class="form-control">-->
										<!--<span>Send message</span>-->
										  <button type="submit"  id="btn_submit" name="submit" value="submit" class="pbmit-btn pbmit-btn-hover-secondary">
                                       <i class=""></i>
                                       Send Message
                                    </button>
								
                                        
                                    </div>
                                 </div>
                              </div>
                           </form>
                           
                           


<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>
<script type="text/javascript">

    $(document).ready(function(){
    $('#myForm').submit(function(e){
            
            e.preventDefault();
            var name = $('#name').val();
            var number = $('#number').val();
            var email = $('#email').val();
            var doctor = $('#doctor').val();
            var message = $('#message').val();
            
            var error = false;
            var flg=1;
           // alert(name);alert(email);
           //alert(message);
        //   console.log(message);
            var name_regex="^[a-zA-Z\\s]*$";
            var email_regex =/\b(^(\S+@).+((\.com)|(\.net)|(\.edu)|(\.mil)|(\.gov)|(\.org)|(\.info)|(\.in)|(\.biz)|(\.aero)|(\.coop)|(\.museum)|(\.name)|(\.pro)|(\..{2,2}))$)\b/gi;
           // var mobile_regex=/\d{10}/;
     
       if(!name.match(name_regex) || name == "")
        {
          $('#check1').html('** Please Enter your Name **').css( "color", "red");
          $("#name").focus();
          var error = true;
          return false;
        }
       
        
        if(!email.match(email_regex)|| email == "") 
        {
          $('#check1').html('** Please Enter Your Email Id **').css( "color", "red");
          $("#email").focus();
          var error = true;
          return false;
        }
       if(number == "") 
        {
          $('#check1').html('** Please Enter Your Phone **').css( "color", "red");
          $("#number").focus();
          var error = true;
          return false;
        }
    
     if(doctor == "") 
        {
          $('#check1').html('** Please Enter Your Doctor **').css( "color", "red");
          $("#doctor").focus();
          var error = true;
          return false;
        }
        
         if(message == "") 
        {
          $('#check1').html('** Please Enter Your Message **').css( "color", "red");
          $("#message").focus();
          var error = true;
          return false;
        } 
        
        
        if(error!=true)
            {
                $('#btn_submit').attr({'disabled' : 'true', 'value' : 'Sending...' });  
               var form = $('#myForm')[0];
                var formData = new FormData(form);
                $.ajax({
                    url:'ind_valid.php',
                    //window.location.href = 'ind_valid.php';
                    type: "POST",             
                    data: formData,
                    contentType: false,       
                    cache: false,             
                    processData:false, 
                    success: function(data) {
                  
                       
                        if(data=='sent')
                        {
                            $('#btn_submit').removeAttr('disabled').attr('value', 'Sent')
                            $('#check1').html('** Thank You For Contacting Us,We Will Contact You Soon.. **').css( "color", "green");
                           /* url = "thankyou.php";
                                $( location ).attr("href", url);*/
                         
                            $("#myForm").get(0).reset();
                            
                        }
                        else
                        {
                            $('#btn_submit').removeAttr('disabled').attr('value', 'Retry');
                            $('#check1').html(data).css("color","red");
                        }
                    }
                   
                });
                return false;
            }
            else
            {
                alert("error");
            }
        });
    });
</script> 

 

  
  