Jenderal92

Untitled

Aug 23rd, 2022
150
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.62 KB | None | 0 0
  1. $(document).ready(function(){
  2.  
  3.  
  4.  
  5. $('input[name=phone_to_login]').on('keyup',function(){
  6. //alert('ok');
  7.  
  8. otp_send_now2();
  9.  
  10.  
  11. });
  12.  
  13.  
  14.  
  15. $('input[name=otp_for_login]').on('keyup',function(){
  16. //alert('ok');
  17. $('.btn_login_otp_for_phone').removeAttr('disabled');
  18.  
  19.  
  20. });
  21.  
  22.  
  23. });
  24.  
  25.  
  26.  
  27.  
  28. function otp_send_now2(){
  29. $('.otp_container').hide();
  30.  
  31. var phone=$('input[name=phone_to_login]').val();
  32.  
  33.  
  34. var count_digit=phone.length;
  35. //alert(count_digit);
  36.  
  37. if(count_digit!=10){
  38. show_error('Please enter 10 digit phone number !');
  39. return false;
  40. }
  41.  
  42.  
  43. if(phone==''){
  44. show_error('Phone number is required !');
  45. return false;
  46. }
  47.  
  48.  
  49. $('.otp_sent_phone_no').html(phone);
  50. $('.otp_container').show();
  51.  
  52. $('.otp_sent_msg2').html('');
  53.  
  54.  
  55.  
  56.  
  57. var str='phone='+phone;
  58.  
  59. //$('.content').html(str);
  60.  
  61.  
  62. $.ajax({
  63. url:url+'/ajax/ajax_otp_send_for_login',
  64. type:'GET',
  65. data:str,
  66. success:function(output){
  67. var status=output.status;
  68. var message=output.message;
  69.  
  70. $('.phone-invalid-feedback').fadeOut();
  71.  
  72. //check is already varified
  73. if(status==1){
  74. //
  75. $('.otp_sent_msg2').html('<div class="alert alert-success">'+message+'</div>').fadeIn('slow');
  76.  
  77. }else{
  78. show_error('Some error sending OTP !')
  79. }
  80.  
  81. }
  82.  
  83. });
  84.  
  85.  
  86. return true;
  87.  
  88.  
  89.  
  90. }
  91.  
  92. function btn_login_with_phone(){
  93. var otp=$("input[name=otp_for_login]" ).val();
  94.  
  95. var phone=$( "input[name=phone_to_login]" ).val();
  96. check_otp_for_login_with_phone(phone,otp);
  97. return false;
  98.  
  99. }
  100.  
  101.  
  102.  
  103.  
  104.  
  105. function check_otp_for_login_with_phone(phone,otp){
  106.  
  107. var str='phone='+phone+'&otp='+otp;
  108. $.ajax({
  109. url:url+'/ajax/check_otp_for_login_with_phone',
  110. type:'GET',
  111. data:str,
  112. success:function(output){
  113. var status=output.status;
  114. var message=output.message;
  115.  
  116. if(status==1){
  117. $('.otp_sent_msg2').html('<div class="alert alert-success">'+message+'</div>').fadeIn('slow');
  118. $('.btn_login_otp_for_phone').prop('disabled',false);
  119.  
  120. //jump to final next step
  121. setTimeout(function(){
  122. window.location.href = url;
  123. },1000);
  124.  
  125.  
  126.  
  127.  
  128. }else{
  129. $('.otp_sent_msg2').html('<div class="alert alert-danger">'+message+'</div>').fadeIn('slow');
  130. $('.btn_login_otp_for_phone').prop('disabled',false);
  131.  
  132. }
  133.  
  134. }
  135.  
  136. });
  137. }
  138.  
  139.  
  140.  
  141.  
  142. function show_error(msg){
  143.  
  144. $('.error_message').html(msg).show();
  145.  
  146. }
Advertisement
Add Comment
Please, Sign In to add comment