  
  <?php   
  $curPageName = substr($_SERVER["SCRIPT_NAME"],strrpos($_SERVER["SCRIPT_NAME"],"/")+1); 
 $curPageName1 = ucfirst(substr($curPageName,0,-4));

?>

      
  
  
  <div class="col-lg-6 text-center mt-5">
        <div class="lead-form rounded p-5 " style="margin-left:100px;"> 
        <form id="myForm" action=""  method="post" enctype="multipart/form-data">
            
            <div id="check1"></div>
    
                                <div>
                                    <h3 class="font-weight-bold" style="color:#000000;margin-bottom: 22px;">Request For a Call!</h3>
                                    <!--<h6 class="pt-3 pb-4 small font-weight-bold" style="color:#000000;">We'll never send you spam</h6>-->
                                </div>
                                <div class="row">
                                    <div class="col-6">
                                        <div class="form-group">
                                            <input type="text" class="form-control form-control-lg" name="name" id="name" placeholder="Name">
                                        </div></div>
                                        <div>
                                          <input type="text" class="form-control" name="page" id="page" value="<?php echo $curPageName1; ?>" hidden >
                                          <div class="help-block with-errors"></div>
                                          </div>
           
                                        <div class="col-6">
                                        <div class="form-group">
                                            <input type="email" class="form-control form-control-lg" name="email" id="email" placeholder="Email">
                                        </div></div>
                                        <div class="col-12">
                                        <div class="form-group">
                                            <input type="text" class="form-control form-control-lg" name="phone" id="phone" placeholder="Phone">
                                        </div>
                                        </div>
                                    </div>
                                    <div class="col-12">
                                        <!--<button class="btn btn-danger btn-lg w-100 mt-3 mt-sm-4" type="submit" >Send Message <i class="lni lni-arrow-right ml-2"></i></button>-->
                                        <button type="submit" id="btn_submit" name="btn_submit" theme-btn  class="btn btn-danger btn-danger-1 btn-lg w-100 mt-3 mt-sm-4" >Send Message</button>
                                        <div>
                                            <!--<span class="d-inline-block mt-4 text-black-50 small">By signing up, you accept our <a href="#">Terms</a> &amp; <a href="#">Privacy Policy</a></span>-->
                                        </div>
                                    </div>
                                </div>
                            </form>
         </div>
         
           </div>
           
           
           
           
             <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 email = $('#email').val();
            var phone = $('#phone').val();
           
            var error = false;
            var flg=1;

        //   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 (phone == "") 
        {
          $('#check1').html('** Please Enter Your phone **').css( "color", "red");
          $("#phone").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: "contact_valid2.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> 

  
  
  
  
  
  
  
  