<!doctype html>
<html lang="en">
  <head>
    <!-- Required meta tags -->
    <meta charset="utf-8">
  <meta content="width=device-width, initial-scale=1.0" name="viewport">
  <title>Augmenting Intelligence to Buy, Sell and Manage|Meddbot</title>
  <meta content="" name="description">
  <meta content="" name="keywords">
  <script src="https://www.google.com/recaptcha/api.js" async defer></script>

  <!-- Favicons -->
  <link rel="icon" href="<?php echo e(url('assets/img/favicon.png')); ?>" type="image/png" sizes="16x16">

    <!-- Google Font -->
    <link href="https://fonts.googleapis.com/css2?family=Open+Sans:wght@300;400;600;700;800&display=swap" rel="stylesheet">

    <!-- Bootstrap CSS -->
    <link rel="stylesheet" href="<?php echo e(url('assets/css/bootstrap.min.css')); ?>">

    <!-- font awesome js -->
    <script src="https://kit.fontawesome.com/c026154490.js" crossorigin="anonymous"></script>


    <!-- Custom CSS -->
    <link rel="stylesheet" href="<?php echo e(url('assets/css/my-dashstyle.css')); ?>">
    <link href="https://cdnjs.cloudflare.com/ajax/libs/select2/4.0.3/css/select2.min.css" rel="stylesheet" />

    <link href="https://cdnjs.cloudflare.com/ajax/libs/sweetalert/1.1.3/sweetalert.css" rel="stylesheet" />
      
      <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.css" />
    <!--<title>Augmenting Intelligence to Buy, Sell and Manage|Meddbot</title>-->
    <style>
      label.error{
        color: red !important;
        font-size: 12px !important;
        font-weight: 500;
      }
        
       .form-inputs .form-control, span.select2-selection.select2-selection--single {
    border-radius: 0px !important;
}
       .select2-container--default.select2-container--open.select2-container--below .select2-selection--single, .select2-container--default.select2-container--open.select2-container--below .select2-selection--multiple {
    border-radius: 0px !important;
} 
   input[type="password"]::-ms-reveal {
    display: none;
}
    </style>
  </head>
  <body>
    <div class="pageloader" style="display: none;" >
	</div>


<section class="sign-up sign-up-otp">
    <div class="container sigCont">
        <form method="POST" id="buyerregister" action="<?php echo e(route('register')); ?>" enctype="multipart/form-data">
                        <?php echo csrf_field(); ?>
        <div class="sign-upbox" id="page1">
            <div class="row" style="margin: 0;">

                 <div class="col-md-12 col-12 white-boxx">
                  <form>
                    <div class="loginform">
                        <div class="row">
                            <div class="col-12">
                                 <div class="logo reg-logo">
                                <img src="<?php echo e(url('assets/img/logo.png')); ?>" alt="Logo">
                            </div>
                                <h6 class="sign-head">Sign Up</h6>
                            </div>
                           
                            <div class="col-lg-12">
                                <div class="form-inputs">
                                     <div class="form-group">
                                        <label class="label">Establishment Name<sup>*</sup></label>
                                       <input id="name"  type="text" class="form-control <?php $__errorArgs = ['name'];
$__bag = $errors->getBag($__errorArgs[1] ?? 'default');
if ($__bag->has($__errorArgs[0])) :
if (isset($message)) { $__messageOriginal = $message; }
$message = $__bag->first($__errorArgs[0]); ?> is-invalid <?php unset($message);
if (isset($__messageOriginal)) { $message = $__messageOriginal; }
endif;
unset($__errorArgs, $__bag); ?>" name="name" value="<?php echo e(old('name')); ?>"  autocomplete="name" autofocus>
                                        <?php $__errorArgs = ['name'];
$__bag = $errors->getBag($__errorArgs[1] ?? 'default');
if ($__bag->has($__errorArgs[0])) :
if (isset($message)) { $__messageOriginal = $message; }
$message = $__bag->first($__errorArgs[0]); ?>
                                            <span class="invalid-feedback" role="alert">
                                                <strong><?php echo e($message); ?></strong>
                                            </span>
                                        <?php unset($message);
if (isset($__messageOriginal)) { $message = $__messageOriginal; }
endif;
unset($__errorArgs, $__bag); ?>
                                      </div>
                                </div>
                              </div>
                              <div class="col-lg-6">
                                <div class="form-inputs">

                                  <div class="form-group">

                                </div>
                                     <div class="form-group">
                                      
					                        <select class="form-control  js-example-disabled-results" id="buyer_type_new" name="user_type" >
                                                |
                                        <option value="1" selected>Individual Hospital</option>
                                        <option value="7">Group Hospital</option>
                                        <option value="5">Procurement Body</option>
                                        <option value="6">Government Body</option>
                                      </select>
                                      
                                      </div>
                                </div>
                              </div>

                              <input type="hidden" name="usercheck" id="usercheck" value="">
                            <div class="col-lg-6">
                                <div class="form-inputs">
                                     <div class="form-group">
                                        <label class="label">Email Id<sup>*</sup></label>
                                       <input id="email" type="email" class="form-control <?php $__errorArgs = ['email'];
$__bag = $errors->getBag($__errorArgs[1] ?? 'default');
if ($__bag->has($__errorArgs[0])) :
if (isset($message)) { $__messageOriginal = $message; }
$message = $__bag->first($__errorArgs[0]); ?> is-invalid <?php unset($message);
if (isset($__messageOriginal)) { $message = $__messageOriginal; }
endif;
unset($__errorArgs, $__bag); ?>" name="email" value="<?php echo e(old('email')); ?>"  autocomplete="email">
                                        <?php $__errorArgs = ['email'];
$__bag = $errors->getBag($__errorArgs[1] ?? 'default');
if ($__bag->has($__errorArgs[0])) :
if (isset($message)) { $__messageOriginal = $message; }
$message = $__bag->first($__errorArgs[0]); ?>
                                            <span class="invalid-feedback" role="alert">
                                                <strong><?php echo e($message); ?></strong>
                                            </span>
                                        <?php unset($message);
if (isset($__messageOriginal)) { $message = $__messageOriginal; }
endif;
unset($__errorArgs, $__bag); ?>
                                      </div>
                                </div>
                              </div>
                             
                              <div class="col-lg-6">
                                <div class="form-inputs">
                                     <div class="form-group">
                                        <label class="label"> Primary Mobile No<sup>*</sup></label>
                                         <div class="phone-input">
                                              <select id="country_code" name="country_code" class="form-control">
                                          <option value="91" selected>+91</option>
                                          <!-- Add other country codes here -->
                                      </select>
                                        <input type="number" id="phone_no" minlength="10" maxlength="10" class="form-control <?php $__errorArgs = ['phone_no'];
$__bag = $errors->getBag($__errorArgs[1] ?? 'default');
if ($__bag->has($__errorArgs[0])) :
if (isset($message)) { $__messageOriginal = $message; }
$message = $__bag->first($__errorArgs[0]); ?> is-invalid <?php unset($message);
if (isset($__messageOriginal)) { $message = $__messageOriginal; }
endif;
unset($__errorArgs, $__bag); ?>" name="phone_no" value="<?php echo e(old('phone_no')); ?>"  autocomplete="phone_no" autofocus>
                                         </div>
                                       <?php $__errorArgs = ['phone_no'];
$__bag = $errors->getBag($__errorArgs[1] ?? 'default');
if ($__bag->has($__errorArgs[0])) :
if (isset($message)) { $__messageOriginal = $message; }
$message = $__bag->first($__errorArgs[0]); ?>
                                    <span class="invalid-feedback" role="alert">
                                        <strong><?php echo e($message); ?></strong>
                                    </span>
                                <?php unset($message);
if (isset($__messageOriginal)) { $message = $__messageOriginal; }
endif;
unset($__errorArgs, $__bag); ?>
                                      </div>
                                </div>
                              </div>

                              
                              <div class="col-lg-6">
                                <select style="    padding: 8px 0px;border: 0;border-bottom: 1px solid #ccc !important;border: 0;" class="form-select w-100" id="country" name="state" aria-label="Default select example">
                                  
                                  <option value="101">India</option>
                                </select>
                              </div>

                        
                              <div class="col-lg-6">
                                <div class="form-inputs">
                                     <div class="form-group">
                                        <label class="label">Contact Person Name<sup>*</sup></label>
                                       
                                       
                                       <input type="text" id="contact_name"  class="form-control <?php $__errorArgs = ['contact_name'];
$__bag = $errors->getBag($__errorArgs[1] ?? 'default');
if ($__bag->has($__errorArgs[0])) :
if (isset($message)) { $__messageOriginal = $message; }
$message = $__bag->first($__errorArgs[0]); ?> is-invalid <?php unset($message);
if (isset($__messageOriginal)) { $message = $__messageOriginal; }
endif;
unset($__errorArgs, $__bag); ?>" name="contact_name" value="<?php echo e(old('contact_name')); ?>"  autocomplete="contact_name" autofocus>
                                         
                                       <?php $__errorArgs = ['contact_name'];
$__bag = $errors->getBag($__errorArgs[1] ?? 'default');
if ($__bag->has($__errorArgs[0])) :
if (isset($message)) { $__messageOriginal = $message; }
$message = $__bag->first($__errorArgs[0]); ?>
                                    <span class="invalid-feedback" role="alert">
                                        <strong><?php echo e($message); ?></strong>
                                    </span>
                                <?php unset($message);
if (isset($__messageOriginal)) { $message = $__messageOriginal; }
endif;
unset($__errorArgs, $__bag); ?>
                                      </div>
                                </div>
                              </div>

                            <div class="col-lg-6">
                                <div class="form-inputs">
                                     <div class="form-group">
                                        <label class="label">Contact Person Mobile No<sup>*</sup></label>
                                         <div class="phone-input">  
                                             <select id="country_code" name="country_code" class="form-control">
                                          <option value="91" selected>+91</option>
                                          <!-- Add other country codes here -->
                                      </select>
                                            <input type="number" id="contact_phone_no" class="form-control <?php $__errorArgs = ['contact_phone_no'];
$__bag = $errors->getBag($__errorArgs[1] ?? 'default');
if ($__bag->has($__errorArgs[0])) :
if (isset($message)) { $__messageOriginal = $message; }
$message = $__bag->first($__errorArgs[0]); ?> is-invalid <?php unset($message);
if (isset($__messageOriginal)) { $message = $__messageOriginal; }
endif;
unset($__errorArgs, $__bag); ?>" name="contact_phone_no"  pattern="\d{10}"  minlength="10" maxlength="10" value="<?php echo e(old('contact_phone_no')); ?>"  autocomplete="contact_phone_no" autofocus>
                                         </div>
                                       <?php $__errorArgs = ['contact_phone_no'];
$__bag = $errors->getBag($__errorArgs[1] ?? 'default');
if ($__bag->has($__errorArgs[0])) :
if (isset($message)) { $__messageOriginal = $message; }
$message = $__bag->first($__errorArgs[0]); ?>
                                    <span class="invalid-feedback" role="alert">
                                        <strong><?php echo e($message); ?></strong>
                                    </span>
                                <?php unset($message);
if (isset($__messageOriginal)) { $message = $__messageOriginal; }
endif;
unset($__errorArgs, $__bag); ?>
                                      </div>
                                </div>
                              </div>

                              <div class="col-lg-6">
                                <div class="form-inputs">
                                     <div class="form-group">
                                        <label style="z-index: 99;" class="label">Password<sup>*</sup></label>
                                    
                                       <div class="pas-sec">
                                           <input id="password"  type="password" class="form-control <?php $__errorArgs = ['password'];
$__bag = $errors->getBag($__errorArgs[1] ?? 'default');
if ($__bag->has($__errorArgs[0])) :
if (isset($message)) { $__messageOriginal = $message; }
$message = $__bag->first($__errorArgs[0]); ?> is-invalid <?php unset($message);
if (isset($__messageOriginal)) { $message = $__messageOriginal; }
endif;
unset($__errorArgs, $__bag); ?>" minlength="8" name="password"
                                       value="<?php echo e(old('password')); ?>"  autocomplete="password">
                                         
                                         <span toggle="#password-field" class="fa fa-fw field_icon toggle-password fa-eye-slash"></span>
                                         </div>
                                        <?php $__errorArgs = ['password'];
$__bag = $errors->getBag($__errorArgs[1] ?? 'default');
if ($__bag->has($__errorArgs[0])) :
if (isset($message)) { $__messageOriginal = $message; }
$message = $__bag->first($__errorArgs[0]); ?>
                                            <span class="invalid-feedback" role="alert">
                                                <strong><?php echo e($message); ?></strong>
                                            </span>
                                        <?php unset($message);
if (isset($__messageOriginal)) { $message = $__messageOriginal; }
endif;
unset($__errorArgs, $__bag); ?>
                                      </div>
                                </div>
                              </div>
                              <div class="col-lg-6">
                                <div class="form-inputs">
                                     <div class="form-group">
                                        <label class="label">Confirm Password<sup>*</sup></label>
                                         <div class="pas-sec">
                                       <input id="password-confirm" type="password"  class="form-control" name="password_confirmation" minlength="8" value="<?php echo e(old('password_confirmation')); ?>"  autocomplete="password_confirmation">
                                             
                                             <span toggle="#confirm-password-field" class="fa fa-fw field_icon toggle-password2 fa-eye-slash"></span>
                                         </div>
                                      </div>
                                </div>
                              </div>
                              <div class="g-recaptcha" data-sitekey="6LeXBmQqAAAAAHgAy90DbqB0rfVSn2Cw-uqUj7fY"></div>

                              <input id="user_status" type="hidden" class="form-control " name="user_status"  value="0">
                              <div class="col-12">
                                <div  class="green-button">
                                  <input type="submit" class="reg-button" value="Submit" id="next" />
                                 </div>
                             </div>
                        </div>
                    </div>

                  </form>

                </div>
            </div>
        </div>
        <div class="sign-upbox sign-upbox-otp" id="page3" style="display:none">
            <div class="row" style="margin: 0;">
                 <div class="col-md-5 col-12 green-boxes">
                    <div class="fxt-bg-img">
                        <div class="fxt-header">
                            <div class="logo">
                                <img src="<?php echo e(url('assets/img/logo.png')); ?>" alt="Logo">
                            </div>
                          
                        </div>
                    </div>
                 </div>
                 <div class="col-md-7 col-12 white-boxx">

                    <div class="loginform">
                        <div class="row">
                        <div class="col-12">
                                <h6 class="sign-head">OTP Verification</h6>
                            </div>
                            <div class="col-lg-12">
                                <!--<label>Please enter the OTP send to your registered Email Id or Phone Number</label>-->

                                <p id="otpMessage"></p>
                                <div class="form-inputs">
                                     <div class="form-group">
                                        <label class="label mt-2 mb-3 position-relative">OTP<sup>*</sup></label>
<!--                                            <input type="text" id="otp" class="form-control" name="otp"  autocomplete="otp"  autofocus >-->
                                         
                                         
                                         <div class="otp-dflex sm">
                <input  min="0" max="9" pattern="\d*" type="number" onkeyup="onKeyUpEvent(1, event)" placeholder="0" maxlength="1" id="otp1">
                <input min="0" max="9" type="number" onkeyup="onKeyUpEvent(2, event)" placeholder="0" maxlength="1" id="otp2">
                <input min="0" max="9" type="number" onkeyup="onKeyUpEvent(3, event)" placeholder="0" maxlength="1" id="otp3">
                <input min="0" max="9" type="number" onkeyup="onKeyUpEvent(4, event)" placeholder="0" maxlength="1" id="otp4">
                <input min="0" max="9" type="number" onkeyup="onKeyUpEvent(5, event)" placeholder="0" maxlength="1" id="otp5">
                <input min="0" max="9" type="number" onkeyup="onKeyUpEvent(6, event)" placeholder="0" maxlength="1" id="otp6">
            </div> 
                                         
                                         
                                         
                                       <?php $__errorArgs = ['otp'];
$__bag = $errors->getBag($__errorArgs[1] ?? 'default');
if ($__bag->has($__errorArgs[0])) :
if (isset($message)) { $__messageOriginal = $message; }
$message = $__bag->first($__errorArgs[0]); ?>
                                    <span class="invalid-feedback" role="alert">
                                        <strong><?php echo e($message); ?></strong>
                                    </span>
                                <?php unset($message);
if (isset($__messageOriginal)) { $message = $__messageOriginal; }
endif;
unset($__errorArgs, $__bag); ?>
                                      </div>
                                </div>
                              </div>

                            <div class="col-12">
                                <div class="reg-flex">
                                <div class="green-button" style="padding: 15px 0;width: 100%;margin: 0">
                                 
                                  <input type="submit" value="Verify"  style="max-width: 130px;" class="reg-button"  id="otpverify" />
                                 </div><br/>
                                 <div class="green-button" style="padding: 15px 0;width: 100%;margin: 0">
                                    <button style="max-width: 130px;" id="resend" type="submit">Resend</button>
                                 </div>
                                 </div>
                             </div>
                        </div>
                    </div>

                </div>
            </div>
        </div>

          </form>
    </div>
</section>

  
     <script src = "https://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script>
     <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
    <script src="<?php echo e(url('assets/js/bootstrap.min.js')); ?>"></script>
      <script src="<?php echo e(url('assets/js/my-dashjs.js')); ?>"></script>
      <script src="https://cdnjs.cloudflare.com/ajax/libs/sweetalert/1.1.3/sweetalert.min.js"></script>

	 <script src="<?php echo e(URL::to('assets/js/validation/jquery.validate.min.js')); ?>"> </script>
	 <script src="<?php echo e(URL::to('assets/js/validation/additional-methods.js')); ?>"></script>
	 <script src="https://cdnjs.cloudflare.com/ajax/libs/select2/4.0.3/js/select2.min.js"></script>
  <script>
      
$(document).ready(function() {
    $(document).on('click', '.toggle-password', function() {
        // Toggle the icon class between fa-eye and fa-eye-slash
        if ($(this).hasClass("fa-eye-slash")) {
            $(this).removeClass("fa-eye-slash").addClass("fa-eye");
        } else {
            $(this).removeClass("fa-eye").addClass("fa-eye-slash");
        }
        
        // Get the password input field
        var input = $("#password");

        // Toggle the type attribute between 'password' and 'text'
        var inputType = input.attr('type');
        input.attr('type', inputType === 'password' ? 'text' : 'password');
    });
    
});

        
$(document).ready(function() {
    $(document).on('click', '.toggle-password2', function() {
        // Toggle the icon class between fa-eye and fa-eye-slash
        if ($(this).hasClass("fa-eye-slash")) {
            $(this).removeClass("fa-eye-slash").addClass("fa-eye");
        } else {
            $(this).removeClass("fa-eye").addClass("fa-eye-slash");
        }
        
        // Get the password input field
        var input = $("#password-confirm");

        // Toggle the type attribute between 'password' and 'text'
        var inputType = input.attr('type');
        input.attr('type', inputType === 'password' ? 'text' : 'password');
    });
    
});
      
  jQuery.validator.addMethod("nameval", function(value, element) {
    //test user value with the regex
    return this.optional(element) || /^[a-zA-Z\s]+$/.test(value);
  }, "Enter only Albhabets");

  jQuery.validator.addMethod("letters_numbers_special", function(value, element) {
    return this.optional(element) || /^(?=.*?[A-Z])(?=.*?[a-z])(?=.*?[0-9])(?=.*?[#?!@$ %^&*-]).{8,}$/i.test(value);
  //(?=.*[a-zA-Z\d].*)[a-zA-Z\d!@#$%&*]
}, "Password should contain at least one digit, one lower case or upper case and  one special characters");


jQuery.validator.addMethod('notEqualTo', function(value, element, param) {
    // param should be the selector or actual value to compare against
    return this.optional(element) || value !== $(param).val();
}, 'This field cannot be equal to the specified value.');

function shouldValidatePhone() {
            const userType = $('#buyer_type_new').val();
            return userType === '7' || userType === '5' || userType === '6'; // Check if user type is 'Group Hospital' or 'Procurement Body'
        }


document.getElementById('phone_no').addEventListener('input', function (event) {
            let input = event.target;
            if (input.value.length > 10) {
                input.value = input.value.slice(0, 10);
            }
        });

        document.getElementById('contact_phone_no').addEventListener('input', function (event) {
            let input = event.target;
            if (input.value.length > 10) {
                input.value = input.value.slice(0, 10);
            }
        });




jQuery.validator.addMethod("noLeadingZeros", function(value, element) {
    return this.optional(element) || /^[1-9]\d*$/.test(value);
}, "Please enter a valid number without leading zeros");




jQuery.validator.addMethod('reCaptchaMethod', function (value, element, param) {
            if (grecaptcha.getResponse() == ''){
                return false;
            } else {
                // I would like also to check server side if the recaptcha response is good
                return true
            }
        }, 'You must complete the antispam verification');



var validatedata=0;
$("#buyerregister").validate({
    rules: {
        name: {
            required: true,
            nameval: true  // Ensure this is defined
        },
        user_type: {
            required: true
        },
        email: {
            required: true,
            email: true
        },
        reCaptcha: {
                    reCaptchaMethod: true   
                },
        phone_no: {
            required: true,
            digits: true,
            noLeadingZeros: true
        },
        contact_name: {
            required: true,
            nameval: true  // Ensure this is defined
        },
        contact_phone_no: {
            required: true,
            digits: true,
            noLeadingZeros: true,
            notEqualTo: function() {
                            // Apply 'notEqualTo' validation if user type is 'Group Hospital' or 'Procurement Body'
                            return shouldValidatePhone() ? '#phone_no' : null;
                        }
        },
        password: {
            required: true,
            letters_numbers_special: true  // Ensure this is defined
        },
        password_confirmation: {
            required: true,
            equalTo: "#password"
        }
    },
    messages: {
        name: 
        
        {
          required:"This field is required.",
          nameval:"Enter Alphabets Only"
        },
        email: {
            required: "Please enter your email.",
            email: "Please enter a valid email address."
        },
        phone_no:
        {
          required:"This field is required.",
        },
        messages: {
        'recaptcha': {
            required: "Please complete the reCAPTCHA."
        }
      },
        contact_name: 
        {
          required:"This field is required.",
           nameval:"Enter Alphabets Only"
        },
        contact_phone_no: {
            required: "This field is required.",
            notEqualTo: "Contact phone number must be different from your phone number."
        },
        password: {
            required: "Please provide a password.",
            letters_numbers_special: "Password must contain letters, numbers, and special characters."  // Ensure this is defined
        },
        password_confirmation: {
            required: "Please confirm your password.",
            equalTo: "Passwords do not match."
        }
    },
    highlight: function (element) {
        $(element).addClass('error');
    },
    unhighlight: function (element) {
        $(element).removeClass('error');
    },
    errorPlacement: function (error, element) {
      if (element.attr("name") == "recaptcha") {
            error.insertAfter('.g-recaptcha');
            $('.rc-anchor-error-msg-container').show(); 
            $('.rc-anchor-error-msg-container').css('display', 'block');
        } else {
            error.insertAfter(element);
        }
    },

    submitHandler: function(form, e) {

      if (grecaptcha.getResponse() == ''){
                
            swal("", "You must complete the antispam verification", "warning");
        }
    else if(validatedata==0) {
    $(".pageloader").show();
        var email   = $('#email').val();
        var phoneno = $('#phone_no').val();
            var data = {
           _token	:'<?php echo e(csrf_token()); ?>',
            email:email,
            phone:phoneno
          }
  
          $.ajax({
            url:'https://www.meddbot.com/emailexist',
            type: "POST",
            data: data,
            success: function (res) {
              var obj = jQuery.parseJSON(res);
             
              if(res==1){ 
                $(".pageloader").hide();
  
                swal("", "Email Id already exist", "warning");
               }
              if(res==2){
                $(".pageloader").hide();
                swal("", "Phone No already exist", "warning");
              }
              if(res==0){
  
                        var email = $('#email').val();
                        var phoneno = $('#phone_no').val();
                        var otp = Math.floor(100000 + Math.random() * 999999);
    
                        var APP_URL = <?php echo json_encode(url('/setotp')); ?> ;
                        var saveData = $.ajax({
                        type: 'GET',
                        url: APP_URL+'/'+email+'/'+phoneno+'/'+otp,
                        data: { email: email,phoneno: phoneno,otp: otp, _token: '<?php echo e(csrf_token()); ?>' },
                        dataType: "text",
                            success: function(resultData) {

                              console.log(otp);
                               
                              
                            }
                        });
                        var SMS_URL = 'https://www.meddbot.com/twiliosms/' ;
                        var saveData = $.ajax({
                            type: 'POST',
                            url: SMS_URL,
                            data: { phoneno: phoneno, otp:otp, _token: '<?php echo e(csrf_token()); ?>' },
                            dataType: "text",
                            success: function(resultData) {
                              $(".pageloader").hide();
                              $("#page1").hide();  
                              
                              $(".pageloader").hide();
                            $("#page1").hide();

                            var email = $('#email').val();
                            var phoneNo = $('#phone_no').val();

                       
                          var emailParts = email.split('@');
                          var emailPrefix = emailParts[0];
                          var emailDomain = emailParts[1];
                          var obfuscatedEmail = emailPrefix.substring(0, 3) + 'xxxxxxxxxx' + '@' + emailDomain;

                         
                          var phoneLastDigits = phoneNo.slice(-3);
                          var obfuscatedPhoneNo = 'xxxxxxx' + phoneLastDigits;

                       
                          $('#otpMessage').text(
                              'OTP sent on the email id: ' + obfuscatedEmail + ' & Mobile no.: ' + obfuscatedPhoneNo + '. Kindly check and enter below:'
                          );

                          $("#usercheck").val('bkl_medd');

                              $("#page3").show();
                            }
                        });
  
              }
              
            }
          });
  
        }
        else{
          form.submit();
        }

    }

});

$(document).ready(function() {




   $('#otpverify').on('click', function(event) {
       event.preventDefault();
      
       if($('#otp').val()==''){ 

        swal("", "Please Enter a valid OTP", "warning");

       }
       else{
        $(".pageloader").show();


        var email = $('#email').val();
                    var phoneno = $('#phone_no').val();
                    var otp =  $('#otp').val();
                    var APP_URL = <?php echo json_encode(url('/verifyotp')); ?> ;
                    var saveData = $.ajax({
                    type: 'GET',
                    url: APP_URL+'/'+email+'/'+phoneno+'/'+otp,
                    data: { email: email,phoneno: phoneno, _token: '<?php echo e(csrf_token()); ?>' },
                    dataType: "text",
                        success: function(resultData) {
                          console.log(resultData);
                          $(".pageloader").hide();
                          if(resultData == '1'){

                              swal({
                                title: "",
                                text: "OTP is verified successfully",
                                type: "success",
                              }, function () {
                                validatedata=1;
                                $(".pageloader").show();
                                $("form").submit();
                              });

                              }else if(resultData == '0'){
                              swal("", "Please enter a valid OTP", "warning");
                              $("#otp").val('');
                                //alert('Please Enter a valid otp');
                              }else{

                              swal("", "Please enter a valid OTP", "warning");
                              $("#otp").val('');
                                // alert('Please Enter a valid otp');
                              }                           
                    }
                    });
       }
          
    });



   $('#resend').on('click', function(event) {
       event.preventDefault();
       $(".pageloader").show();

                    var email = $('#email').val();
                    var phoneno = $('#phone_no').val();
                    var APP_URL = <?php echo json_encode(url('/checkotp')); ?>

                    var saveData = $.ajax({
                    type: 'GET',
                    url: APP_URL+'/'+email+'/'+phoneno,
                    data: { email: email,phoneno: phoneno, _token: '<?php echo e(csrf_token()); ?>' },
                    dataType: "text",
                        success: function(resultData) {
                         var res = JSON.parse(resultData);
                         console.log(res);
                         if(res.otp_code !== null && res.otp_code !== ''){
                             var otp = res.otp_code;
                         }else{
                            var otp = Math.floor(100000 + Math.random() * 999999);
                         }
                         var APP_URL = <?php echo json_encode(url('/resendotp')); ?> ;
                            var saveData = $.ajax({
                            type: 'GET',
                            url: APP_URL+'/'+email+'/'+phoneno+'/'+otp,
                            data: { email: email,phoneno: phoneno,otp: otp, _token: '<?php echo e(csrf_token()); ?>' },
                            dataType: "text",
                                success: function(resultData) {
                                 
                                 }
                            });

                            var SMS_URL = 'https://www.meddbot.com/twiliosms/' ;
                            var saveData = $.ajax({
                                type: 'POST',
                                url: SMS_URL,
                                data: { phoneno: phoneno, otp:otp, _token: '<?php echo e(csrf_token()); ?>' },
                                dataType: "text",
                                success: function(resultData) {
                                  $(".pageloader").hide();
                                  swal("", "OTP send to your registered Email Id or Phone Number", "success");

                                }
                            });
                           


                    }
                    })


    });
});


$("#backpage").click(function(){
$("#page2").hide();
  $("#page1").show();
});
   
var $disabledResults = $(".js-example-disabled-results");
$disabledResults.select2();
</script>
      <!--     OTP auto tabing script          -->
    <script>
      function getCodeBoxElement(index) {
        return document.getElementById('otp' + index);
      }
      function onKeyUpEvent(index, event) {
        const eventCode = event.which || event.keyCode;
        if (getCodeBoxElement(index).value.length === 1) {
          if (index !== 6) {
            getCodeBoxElement(index+ 1).focus();
          } else {
            getCodeBoxElement(index).blur();
            // Submit code
            console.log('submit code ');
          }
        }
        if (eventCode === 8 && index !== 1) {
          getCodeBoxElement(index - 1).focus();
        }
      }
      function onFocusEvent(index) {
        for (item = 1; item < index; item++) {
          const currentElement = getCodeBoxElement(item);
          if (!currentElement.value) {
              currentElement.focus();
              break;
          }
        }
      }
        
    
     document.querySelectorAll('input[type="number"]').forEach(input =>{
         input.oninput = () =>{
             if(input.value.length > input.maxLength) input.value = input.value.slice(0, input.maxLength);
         };
     }) ;  
        
        
        
        
        
        
        
        
        
        
 $(".modal").on('shown.bs.modal', function () {
    $(this).find("#otp1").focus();
});   
        
        
    </script>
</html>
<?php /**PATH /home/meddbot/public_html/resources/views/auth/buyerregister.blade.php ENDPATH**/ ?>