Edit File: update_phone.blade.php
@extends('layouts.delegates_dashboard_layout') @section('title') {{Session::has('lang')&&Session::get('lang')=='en'?' update phone':' تعديل رقم الجوال'}} @endsection @section('style') @endsection @section('content') <div class="table-cont p-2 "> <div class="row align-items-center"> <div class="dash-title col-md p-0 mt-0"> <h6 class="bold">{{trans('delegates_dashboard.settings')}}</h6> <p class="mb-1">{{trans('delegates_dashboard.settings')}} / {{trans('delegates_dashboard.profile_settings')}}</p> </div> </div> <form id="updateform" method="post" enctype="multipart/form-data"> @csrf <div class=" white-bg round7 mb-3 mt-2 p-3"> <h6 class="bold border-bottom pt-3 pb-3 mb-4"> {{trans('delegates_dashboard.update_phone')}}</h6> <div class="form-group"> <div class="row justify-content-center" style="direction: ltr"> <div class="pt-1 d-inline-block code-input pb-1 pl-0 pr-2"> <input name='code[]' class='code-input form-control code' required/> </div> <div class="pt-1 d-inline-block code-input pb-1 pl-0 pr-2"> <input name='code[]' class='code-input form-control code' required/> </div> <div class="pt-1 d-inline-block code-input pb-1 pl-0 pr-2"> <input name='code[]' class='code-input form-control code' required/> </div> <div class="pt-1 d-inline-block code-input pb-1 pl-0 pr-2"> <input name='code[]' class='code-input form-control code' required/> </div> <div class="pt-1 d-inline-block code-input pb-1 pl-0 pr-2"> <input name='code[]' class='code-input form-control code' required/> </div> <div class="pt-1 d-inline-block code-input pb-1 pl-0 pr-2"> <input name='code[]' class='code-input form-control code' required/> </div> </div> </div> </div> <button type="submit" id="updatebtn" class="button1 mt-3 material-button" >{{trans('delegates_dashboard.save_changes')}} </button> </form> </div> @endsection @section('scripts') <script> $(function(){ $('.side-button .active').siblings('.side-dropdown').slideDown(); }); </script> <script> const inputElements = [...document.querySelectorAll('input.code-input')] inputElements.forEach((ele,index)=>{ ele.addEventListener('keydown',(e)=>{ if(e.keyCode === 8 && e.target.value==='') inputElements[Math.max(0,index-1)].focus() }) ele.addEventListener('input',(e)=>{ const [first,...rest] = e.target.value e.target.value = first ?? '' if(index!==inputElements.length-1 && first!==undefined) { inputElements[index+1].focus() inputElements[index+1].value = rest.join('') inputElements[index+1].dispatchEvent(new Event('input')) } }) }) function onSubmit(e){ e.preventDefault() const code = [...document.getElementsByTagName('input')] .filter(({name})=>name) .map(({value})=>value) .join('') console.log(code) } </script> <script> $("#updatebtn").on('click',function(e){ e.preventDefault(); var form = $('#updateform').get(0); var formData = new FormData(form); var oldText = $(this).text(); $(this).prop('disabled', true).css({ opacity:'0.5' }).text("{{trans('delegates_dashboard.loading')}}"); $.ajax({ url:"{{ route('delegates_dashboard.changedPhoneActivation') }}", type:"POST", data: formData, dataType: "json", processData: false, contentType: false, cache: false, success:function(data){ $('#updatebtn').removeAttr("disabled").css({ opacity:'1' }).text(oldText); if(data.key =='success'){ Swal.fire({ title: data.msg, position:'top', timer: 15000, type:'success', showCloseButton: false, showConfirmButton:false, animation: true }) location.assign(data.url); }else{ Swal.fire({ title: data.msg, position:'top', timer: 3000, type:'error', showCloseButton: false, showConfirmButton:false, animation: true }) } } }); }); </script> @endsection
Back to File Manager