@if(Agent::isMobile())
@extends('layouts.main')
@section('isMobile')

<form method="POST" action="{{ route('register') }}">
        @csrf

        <label for="username">Username:</label>
        <input type="text" id="username" name="username" value="{{ old('username') }}" required>
        @error('username')
            <span>{{ $message }}</span>
        @enderror

        <label for="password">Password:</label>
        <input type="password" id="password" name="password" required>
        @error('password')
            <span>{{ $message }}</span>
        @enderror

        <label for="konfirmasi_pass">Konfirmasi Password:</label>
        <input type="password" id="konfirmasi_pass" name="konfirmasi_pass" required>
        @error('konfirmasi_pass')
            <span>{{ $message }}</span>
        @enderror

        <label for="email">Email:</label>
        <input type="email" id="email" name="email" value="{{ old('email') }}" required>
        @error('email')
            <span>{{ $message }}</span>
        @enderror

        <label for="no_whatsapp">Nomor WhatsApp:</label>
        <input type="text" id="no_whatsapp" name="no_whatsapp" value="{{ old('no_whatsapp') }}" required>
        @error('no_whatsapp')
            <span>{{ $message }}</span>
        @enderror

        <label for="bank">Nama Bank:</label>
        <input type="text" id="bank" name="bank" value="{{ old('bank') }}" required>
        @error('bank')
            <span>{{ $message }}</span>
        @enderror

        <label for="pemilik_rekening">Pemilik Rekening:</label>
        <input type="text" id="pemilik_rekening" name="pemilik_rekening" value="{{ old('pemilik_rekening') }}" required>
        @error('pemilik_rekening')
            <span>{{ $message }}</span>
        @enderror

        <label for="norek">Nomor Rekening:</label>
        <input type="text" id="norek" name="norek" value="{{ old('norek') }}" required>
        @error('norek')
            <span>{{ $message }}</span>
        @enderror

        <label for="refferal">Refferal:</label>
        <input type="text" id="refferal" name="refferal" value="{{ old('refferal') }}">
        @error('refferal')
            <span>{{ $message }}</span>
        @enderror

        <label for="captcha_asli">Captcha Asli:</label>
        <input type="text" id="captcha_asli" name="captcha_asli" required>
        @error('captcha_asli')
            <span>{{ $message }}</span>
        @enderror

        <!-- Tambahkan field untuk captcha sesuai dengan kebutuhan -->

        <button type="submit">Register</button>
    </form>
@endsection



@else



@section('isDesktop')
<div class="content my01">
<div class="register container">
<div class="row">

<div class="col-md-3">
</div>

<div class="col-md-8 clearfix">
<div class="p-title">
<span id="step_title" class="skew" data-title="Daftar Akun"> <span>Daftar Akun </span></span>
</div>

<form class="register-form form form-horizontal needs-validation" [formgroup]="register-form" id="registerForm1" method="post" action="{{ route('register') }}" enctype="multipart/form-data" novalidate="novalidate">

            <input type="hidden" name="stage_val" value="0" id="stage_val">
            @csrf


            <div class="register_form_one">
              <div class="sub-title">
                Rincian Akun
              </div>

              <div class="form-group  ">
                <div class="col-md-5">
                  <label>Nama pengguna</label>
                </div>
                <div class="col-md-7">
                  <input type="text" class="form-control " placeholder="" name="name" id="user_name" required="" autocomplete="nope">
                  <small class="text-left">* Nama akun harus 6-12 karakter, hanya menggunakan huruf dan/atau angka (0-9) dan tidak ada simbol (@#$~%&amp;)                    <br> cth: <b>namaakun1</b>
                  </small>
                </div>
              </div>
              <div class="form-group  ">
                <div class="col-md-5">
                  <label>Kata sandi</label>
                </div>
                <div class="col-md-7">
                  <input type="password" class="form-control" name="password" id="password_1" placeholder="" required="" autocomplete="new-password">
                  <small class="text-left">*  Minimal 8 karakter dan memiliki min 1 alfabet, 1 angka dan 1 karakter khusus  (!@#$%^&amp;*()_+)<br> cth: <b>  password1@</b> </small>

                </div>
              </div>
              <div class="form-group">
                <div class="col-md-5">
                  <label>Konfirmasi Sandi</label>
                </div>
                <div class="col-md-7">
                  <input type="password" class="form-control input_text" name="password_confirmation" id="password_confirmation" placeholder="" required="" autocomplete="new-password">
                </div>
              </div>
              <div class="sub-title">
                Contact info
              </div>
              <div class="form-group">
                <div class="col-md-5">
                  <label>Alamat email</label>
                </div>
                <div class="col-md-7">
                  <input type="email" class="form-control " placeholder="" name="email" value="" required="" autocomplete="off">
                  <div class="loader-b" id="email-validate-loader" style="position: absolute; display: block; top: 3px; right: 23px; width: 10px; height: 10px; left: inherit; display:none;"></div>
                  <small class="text-left">* Silakan isi alamat email yang benar </small>
                </div>
              </div>



              <div class="form-group">
                <div class="col-md-5">
                  <label>Nomor telepon</label>
                </div>
                <div class="col-md-7">
                  <div class="input-group">

                    <input type="tel" class="form-control" placeholder="" id="mobile_no" name="mobile_no" required="" autocomplete="off" maxlength="20">

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





              <div class="form-group" id="refCode_formgrp">
                <div class="col-xs-5  col-md-5">
                  <label>Kode Referensi / Afiliasi</label>
                </div>
                <div class="col-xs-7  col-md-7">
                  <input type="text" class="form-control" id="refCodeInput" name="ref_code" maxlength="50" autocomplete="off">
                  <small class="text-left">(Optional) Kosongkan jika tidak ada </small>
                </div>
              </div>

              <div class="form-group">
                <div class="col-xs-4 text-right" style="padding-top:15px">
                </div>
                <input type="hidden" value="1" name="isRegHasBank">
                <div class="col-xs-8 text-right" style="padding-top:15px" id="register_form_two_next_btn">
                  <button type="button" class="btn btn-secondary next_btn">Lanjut</button>
                </div>
              </div>

            </div>
            <div class="register_form_two" id="form_dua">
              <input type="hidden" value="1" name="isRegHasBank">
              <div class="sub-title">
                Informasi bank
              </div>
              <div class="form-group">
                <div class="col-md-5">
                  <label>Nama Sesuai Rekening</label>
                </div>
                <div class="col-md-7">
                  <input type="text" class="form-control" id="name1" placeholder="" name="acc_name" maxlength="100">
                  <small class="text-left">* Nama yang terdaftar harus sesuai dengan nama rekening bank yang digunakan untuk menyetor dan menarik dana.</small>
                </div>
              </div>
              <div class="form-group">
                <div class="col-md-5 ">
                  <label for="method" style="padding-top: 7.5px;">Jenis Akun Transaksi<span class="text-danger">*</span></label>
                </div>
                <div class="col-md-7">
                  <div class="row">
                    <div class="col-xs-6 radio_2">
                      <input class=" " name="method" id="radioBank5" checked="" type="radio" value="5">
                      <label class=" " for="radioBank5">
                        <span class="radio-title">
                          Bank                        </span>
                        <span class="marked">
                          <i class="icon-checkmark"></i>
                        </span>
                      </label>
                    </div>
                    <div class="col-xs-6 radio_2">
                      <input class=" " name="method" id="radioEwallet7" type="radio" value="7">
                      <label class="" for="radioEwallet7">
                        <span class="radio-title">
                          E-wallet                        </span>
                        <span class="marked">
                          <i class="icon-checkmark"></i>
                        </span>
                      </label>
                    </div>
                  </div>
                </div>
              </div>
              <div class="form-group" id="isShowBankOptions">
                <div class="col-md-5">
                  <label>Bank</label>
                </div>
                <div class="col-md-7">
                  <select class="form-control" data-plugin="bank_list" id="bankOpts--register" name="bank_name">
                    <option selected="" value="">- Silahkan pilih -</option>
                    
                    <option value="BCA" data-bcode="BCA">BCA</option>
                    <option value="BNI" data-bcode="BNI">BNI</option>
                    <option value="MANDIRI" data-bcode="MDR">MANDIRI</option>
                    <option value="BRI" data-bcode="BRI">BRI</option>
                    <option value="BANK LAIN LAIN" data-bcode="Other">BANK LAIN LAIN</option>
                  </select>
                </div>
              </div>
              <div class="form-group" id="isShowEwalletOptions" style="display:none;">
                <div class="col-md-5">
                  <label>E-wallet</label>
                </div>
                <div class="col-md-7">
                  <select class="form-control" data-plugin="bank_list" id="ewalletOpts--register" name="bank_name" disabled="">
                    <option selected="" value="">- Silahkan pilih -</option>

                    <option value="DANA">DANA</option>
                    <option value="GOPAY">GOPAY</option>
                    <option value="OVO">OVO</option>
                    <option value="LINK AJA">LINK AJA</option>
                    <option value="SAKUKU">SAKUKU</option>

                  </select>
                </div>
              </div>
              <div class="form-group">
                <div class="col-md-5">
                  <label id="isShowBankLable">No. Rekening Bank</label>
                  <label id="isShowEwalletLable" style="display:none;">No. E-Wallet</label>
                </div>
                <div class="col-md-7">
                  <input type="tel" class="form-control " placeholder="" name="acc_no" id="acc_no" required="" autocomplete="off" minlength="8" maxlength="20">
                  <div class="loader-b" id="accno-validate-loader" style="position: absolute; display: block; top: 3px; right: 23px; width: 10px; height: 10px; left: inherit; display:none;z-index:10;"></div>
                  <small class="text-left">* Pastikan rekening anda Valid, Aktif, dan belum terdaftar di situs ini</small>
                </div>
              </div>

              <div class="form-group row no-gutters">
                <div class="col-xs-4 col-md-5" style="margin-left: 15px;">
                  <label>Captcha</label>
                </div>
                <div class="col-xs-3 col-md-2">
                  <input type="tel" id="captcha" class="form-control" name="captcha" maxlength="4" autocomplete="off" style="height: 38px" />
              </div>
              <img src="{{ captcha_src() }}" id="captcha-image" alt="Capimg">
              <button class="btn-refresh-captcha compact circular ui icon button" type="button">
                <i class="icon-refresh"></i>
              </button>
            </div>

            <script>
              $(document).ready(function() {
                $(".btn-refresh-captcha").on("click", function() {
                  $.ajax({
                    type: "GET",
                    url: "/refresh-captcha",
                    success: function(data) {
                      $("#captcha-image").attr("src", data);
                    }
                  });
                });
              });
            </script>

            <div class="form-group form-check submit-box">
              <div class="col-md-12">
                <div class="checkbox">
                  <label><input type="checkbox" id="terms" name="terms" value="on">
                    &nbsp;
                    Dengan memilih tombol DAFTAR, saya menyatakan bahwa saya 18 tahun atau lebih dan saya tidak didiskualifikasi berdasarkan hukum untuk terlibat dalam perjudian. Saya telah membaca dan menyetujui Syarat &amp; Ketentuan. Melihat                        <a href="/info/terms-terms_conditions" target="_blank">Syarat &amp; Ketentuan </a>
                  </label>
                </div>
              </div>
              <div class="col-md-12">
                <div class="checkbox">
                  <label>
                    <input type="checkbox" id="RememberMe" name="remember_me" value="1" checked="">
                    <p class="text-left">
                      Ingat saya
                    </p>
                  </label>
                </div>
              </div>
            </div>
            <div class="form-group">
              <div class="col-xs-4 text-right" style="padding-top:15px" id="register_form_two_prev_btn">
                <button type="button" class="btn btn-tertiery prev_btn">Sebelumnya</button>
              </div>
              <div class="col-xs-8 text-right" style="padding-top:15px;" id="register_form_two_submit_btn">
                <button type="submit" class="btn btn-secondary">Daftar</button>
              </div>
            </div>
          </div>
        </form>


<!-- <app-spinner *ngIf="requestState.inProgress" ></app-spinner> -->
</div>

</div>

</div>

</div>

<script type="text/javascript">
$(document).ready(function() {

/*setting minlength 10 for mobile number to IDR */
var mob_minlength = 5;
if (window.currencyCode == 'IDR') {
mob_minlength = 10;
}
/*setting minlength 10 for mobile number to IDR */


var formSteps = parseInt('1'); //count fr  0
var pwd_regex = /^[A-Za-z\d!@#$%^&*()_+]{8,20}$/;
var accname_regex = /^\s{0,1}[a-zA-Z-.\/,']+(?:\s[a-zA-Z]+)*\s{0,1}$/;
var ref_code = "";

if (!!ref_code) {
localStorage.setItem('refCode', ref_code);
$('#refCode_formgrp').show();
} else {
var refCode = localStorage.getItem('refCode');
if (!!refCode) {
$('#refCodeInput').val(refCode);
$('#refCodeInput').val(refCode).attr('readonly', true);
$('#txt-refCode__reg').text(refCode);
$('#refCode_formgrp').show();
}
}




$('input[name=method]').change(function() {
$('#bankOpts--register').val(null);
$('#ewalletOpts--register').val(null);
$("#acc_no").val(null);

if ($(this).val() == '7') {
$('#isShowBankOptions,#isShowBankLable').hide();
$('#isShowEwalletOptions,#isShowEwalletLable').show();

$('#bankOpts--register').prop('disabled', true);
$('#ewalletOpts--register').prop('disabled', false);
$("#acc_no").attr("minlength", '1');
$("#acc_no").attr("maxlength", "20");
} else {
$('#isShowBankOptions,#isShowBankLable').show();
$('#isShowEwalletOptions,#isShowEwalletLable').hide();
$('#bankOpts--register').prop('disabled', false);
$('#ewalletOpts--register').prop('disabled', true);
$("#acc_no").attr("minlength", window.accLength);
}
});

var thankyou = "Terima kasih atas pendaftaran Anda";
var email_regex = /^[a-zA-Z0-9._-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,4}$/i;

var username = $("#username").val();
var acc_no = $("#acc_no").val();
var email_id = $("#email_id").val();
var mobile_no = $("#mobile_no").val();


$regi_validator = $("#registerForm1").validate({
rules: {
acc_name: {

required: true,
pattern: accname_regex,
//pattern: /^[a-z A-Z]+$/,
minlength: 3
},

name: {
required: true,
minlength: 6,
maxlength: 12,
pattern: /^[a-zA-Z0-9]+$/,

},
ref_code: {
maxlength: 50,
pattern: /^[a-zA-Z0-9]+$/,

},

acc_no: {
required: function() {
return window.isRegWAcc;
},
minlength: function(element) {
var bankAccLimit = $("#acc_no").attr('minlength');
return $("#acc_no").attr('minlength');
},
maxlength: function(element) {
return $("#acc_no").attr('maxlength');
},
pattern: /^[0-9]+$/,

},
bank_name: {
required: function() {
return window.isRegWAcc;
},
},
password: {
required: true,
minlength: 8,
maxlength: 20,
pattern: pwd_regex
},
password_confirmation: {
required: true,
equalTo: '#password_1'
},
email: {
required: true,
email: true,

},
mobile_no: {
required: true,
minlength: mob_minlength,
pattern: /^[0-9]{5,20}$/,
},

terms: {
required: true,
},
captcha: {
required: true,
minlength: 4,
maxlength: 4,
remote: {
url: "/validate-captcha",
type: "post",
dataType:
"json",
complete:
function (
data
) {
console.log(data);
if (
data.responseJSON ==
"refreshCaptcha"
)
$(
".btn-refresh-captcha"
).trigger(
"click"
);
}
}
},
},
// Specify validation error messages
messages: {

name2: {
required: "Diperlukan Nama Lengkap",
pattern: "Nama lengkap hanya boleh terdiri dari huruf dan spasi, untuk spasi berturut-turut tidak diperbolehkan",
minlength: "Diperlukan minimal 3 karakter",

},
name: {
required: "Diperlukan Nama Akun",
pattern: "Nama akun hanya dapat terdiri dari huruf dan angka",
minlength: "Diperlukan minimal 6 karakter",
maxlength: "Maksimal 12 karakter saja",
remote: "Nama Akun tidak tersedia"
},
acc_no: {
required: "Diperlukan nomor rekening bank",
pattern: "Nomor rekening bank hanya dapat terdiri dari angka",

minlength: function(element) {
var min_length = $("#acc_no").attr('minlength');
var str = "Diperlukan minimal :acc_length karakter";
var minlength_msg = str.replace(":acc_length", min_length);
return minlength_msg;
},
maxlength: "Maksimal 20 karakter saja",
remote: "Nomor Rekening Sudah Terdaftar"
},
bank_name: {
required: "Bank Diperlukan",
},
password: {
required: "Diperlukan Kata Sandi",
minlength: "Diperlukan minimal 8 karakter",
maxlength: "Maksimal 20 karakter saja",
},
password_confirmation: {
required: "Konfirmasi Kata Sandi Diperlukan",
equalTo: "Konfirmasi Kata Sandi tidak sama dengan kata sandi",
},
email: {
required: "Diperlukan Email",
email: "Email tidak valid",
remote: "Email tidak tersedia"
},
mobile_no: {
required: "Diperlukan nomor ponsel",
minlength: "Diperlukan minimal 10 angka",
pattern: "Nomor ponsel harus terdiri dari nomor saja dan minimal 5 nomor.",
remote: "Nomor ponsel tidak tersedia"
},
terms: {
required: "Diperlukan Konfirmasi Syarat & Ketentuan",
},
captcha: {
required: "Captcha Diperlukan",
remote: "Captcha tidak valid"
},

},


errorElement: "em",
errorPlacement: function(error, element) {
// Add the `help-block` class to the error element
error.addClass("help-block");

element.addClass("has-feedback");
if (element.prop("type") === "checkbox") {
error.insertAfter(element.parent("label"));
} else {
error.insertAfter(element);
}

function addErrorEleIcon(element) {
if (!$(element).next("i")[0]) {
$("<i class='icon-cancel form-control-feedback absolute'></i>").insertAfter(
element);
}
}
let eleId = element.id;

if (eleId == 'email' && !$('#email').hasClass('pending')) {
addErrorEleIcon(element);
} else if (eleId == 'mobile_no' && !$('#mobile_no').hasClass('pending')) {
addErrorEleIcon(element);
} else if (eleId == 'acc_no' && !$('#acc_no').hasClass('pending')) {
addErrorEleIcon(element);
} else {
addErrorEleIcon(element);
}
},

success: function(label, element) {

function addSuccessEleIcon(element) {
if (!$(element).next("i")[0]) {
$("<i class='icon-checkmark  form-control-feedback absolute'></i>")
.insertAfter(element);
}
}
let eleId = element.id;

if (eleId == 'email' && !$('#email').hasClass('pending')) {
addSuccessEleIcon(element);
} else if (eleId == 'mobile_no' && !$('#mobile_no').hasClass('pending')) {
addSuccessEleIcon(element);
} else if (eleId == 'acc_no' && !$('#acc_no').hasClass('pending')) {
addSuccessEleIcon(element);
} else {
addSuccessEleIcon(element);
}
},
highlight: function(element, errorClass, validClass) {
function chgEleShowError(element) {
$(element).addClass("has-error").removeClass("has-success");
$(element).next("i").addClass("icon-cancel").removeClass("icon-checkmark");
}
let eleId = element.id;

if (eleId == 'email' && !$('#email').hasClass('pending')) {
chgEleShowError(element);
} else if (eleId == 'mobile_no' && !$('#mobile_no').hasClass('pending')) {
chgEleShowError(element);
} else if (eleId == 'acc_no' && !$('#acc_no').hasClass('pending')) {
chgEleShowError(element);
} else {
chgEleShowError(element);
}
},
unhighlight: function(element, errorClass, validClass) {
function chgEleShowSuccess(element) {
$(element).addClass("has-success").removeClass("has-error");
$(element).next("i").addClass("icon-checkmark").removeClass("icon-cancel");
}

let eleId = element.id;

if ($(element).attr('id') == 'email' && !$('#email').hasClass('pending')) {
chgEleShowSuccess(element);
} else if (eleId == 'mobile_no' && !$('#mobile_no').hasClass('pending')) {
chgEleShowSuccess(element);
} else if (eleId == 'acc_no' && !$('#acc_no').hasClass('pending')) {
chgEleShowSuccess(element);
} else {
chgEleShowSuccess(element);
}
},
submitHandler: function(form) {
$('button[type=submit]').prop('disabled', true);

var curr_stage = parseInt($("#stage_val").val());
if (formSteps == curr_stage) {

form.submit();
} else {
$('button[type=submit]').prop('disabled', false);
}
}
});

$('#mobile_no').keyup(function() {
if ($('#mobile_no').hasClass('pending')) {
$('#mobile_no-error').text("Memvalidasi nomor ponsel...");
$('#mobile-validate-loader').show();
}
});

$('#email').keyup(function() {
if ($('#email').hasClass('pending')) {
$('#email-error').text("Memvalidasi email...");
$('#email-validate-loader').show();
}
});

$('#acc_no').keyup(function() {
if ($('#acc_no').hasClass('pending')) {
$('#acc_no-error').text("Memvalidasi nomor rekening bank...");
$('#accno-validate-loader').show();
}
});

$("#registerForm1").submit(function(e) {
e.preventDefault();
if ($('#mobile_no').hasClass('pending') || $('#email').hasClass('pending')) {
validatingForm(0, true);
return false;
} else if (!$("#registerForm1").valid()) {
sweetAlert("Formulir memiliki bidang yang tidak valid. Silahkan dicek kembali",
'warning');
return false;
} else {
return true;
}
});

var stepTwo_lang = "Langkah";
var stepLast_lang = "Langkah Terakhir";
$('.next_btn').on('click',
async function() {
const avail = await check_username_phone();

if (avail) {
validatingForm(0, false);
}
});

function validatingForm(times,
isSubmit) {
times++;
if (times > 2) {
sweetAlert("Formulir memiliki bidang yang tidak valid. Silahkan dicek kembali", 'warning');
}

if (($('#mobile_no').hasClass('pending') || $('#email').hasClass('pending'))) {
showLoadingImgFn();
}

setTimeout(function() {
if ($("#registerForm1").valid()) {
if (!$('#mobile_no').hasClass('pending') && !$('#email').hasClass('pending')) {
removeLoadingImgFn();

if (!isSubmit) {
//if not submit only switch form
switchForm(1);
} else {
return $("#registerForm1").submit();
}
} else {
validatingForm(times, isSubmit);
}
} else if ($('#mobile_no').hasClass('pending') || $('#email').hasClass('pending')) {
validatingForm(times, isSubmit);
} else {
removeLoadingImgFn();
sweetAlert("Formulir memiliki bidang yang tidak valid. Silahkan dicek kembali",
'warning');
}
},
1000);
}


function switchForm(val) {
var curr_stage = $("#stage_val").val();
var up_val = parseInt(curr_stage) + val; // val -1 = previous tab, 1 = next tab
$("#stage_val").val(up_val);
window.scrollTo(0,
0);
switch (up_val) {
case 0:
$('.register_form_one').css("display",
"block");
$('.register_form_two,.register_form_three').css("display",
"none");
$('#step_title').find('span').text($('#step_title').attr('data-title'));
break;
case 1:

$('.register_form_one,.register_form_three').css("display",
"none");
$('.register_form_two,.prev_btn').css("display",
"block");
$('#step_title').find('span').text($('#step_title').attr('data-title') + ' - ' +
stepTwo_lang + ' 2 ');
break;
case 2:

$('.register_form_one,.register_form_two').css("display",
"none");
$('.register_form_three,.prev_btn').css("display",
"block");
$('#step_title').find('span').text(stepLast_lang);
break;

}
}

$('.prev_btn').on('click',
function() {
switchForm(-1);
});

$(document).on('keyup',
function(event) {
event.preventDefault();
if (event.which == 13) {
var el = $(this).find('#registerForm1 .next_btn:visible')
if (!el) {

el = $(this).find('#registerForm1  button[type="submit"]:visible');
}
el.click();
}
});

/*min and max length changing based on bank id*/
var default_minlength, default_maxlength, selectedBank;
default_minlength = $("#acc_no").attr('minlength');
default_maxlength = $("#acc_no").attr('maxlength');
$('#bankOpts--register').on('change',
function() {
selectedBank = $(this).find("option:selected").attr('data-bcode');
var checkBankLimit = window.bankAccLength(selectedBank, default_minlength,
default_maxlength);
console.log(checkBankLimit.min_len);
$("#acc_no").attr('minlength', checkBankLimit.min_len);
$("#acc_no").attr('maxlength', checkBankLimit.max_len);
});
/*min and max length changing based on bank id*/
});
if (window.location.href.indexOf("ref") > -1) {
var url = new URL(location);
url.searchParams.delete('ref');
history.pushState(null, document.title, url);
}


async function check_username_phone() {
const username = 'username='+ btoa($('input[name="name"]').val()),
phone = '&phone=' + btoa($('#mobile_no').val());

let final = null;
//get check phone number & username
await $.get('{{ URL::to('username_phone') }}?' + username + phone, function(result) {

result = typeof result === 'string' ? JSON.parse(result): result;
if (!result.username) {
$('#name-error').text("Error, Name Sudah Ada");

$('input[name=name]').removeClass('has-success');
$('input[name=name]').addClass('has-error');
$('input[name=name]').next().removeClass('icon-checkmark').addClass('icon-cross');
}

if (!result.phone) {
$('#mobile_no-error').text('Nomor Telp sudah ada');
$('#mobile_no').removeClass('has-success');
$('#mobile_no').addClass('has-error');
$('#mobile_no').next().removeClass('icon-checkmark').addClass('icon-cross');
}

final = result.username && result.phone;
});

return final;
}
</script>
@endsection
@endif