Combine two field in email field

  javascript, laravel, php

laravel

I’m struggling to put the result of two concatme fields in another field input.
I would like to put the results of response in the email field input.

The thing I would like to achieve is to make it easier for the user to log in to the system without putting the whole email address [email protected]

here is the code so far.

@extends('layouts.app')

@section('content')
<div class="container">
    <div class="row">
        <div class="col-md-8 col-md-offset-2">

            @include('auth/banner')

            <div class="panel panel-default panel-shaded">
                
                <div class="panel-body">

                    @action('login_form.before')

                    <form class="form-horizontal margin-top" method="POST" action="{{ route('login') }}">
                        {{ csrf_field() }}

                        <div class="form-group{{ $errors->has('email') ? ' has-error' : '' }}">
                            <label for="email" class="col-md-4 control-label">{{ __('Email Address') }}</label>

                            <div class="col-md-6">
 
                                <!-- SCRIPT -->
                                <script type="text/javascript">
                                  function concatme()
            {
                var num1 = document.getElementById("num1").value;
                var num2 = document.getElementById("num2").value;
                document.getElementById("response").innerText = num1 + '' +num2;
            }
            </script>
                                <!-- FIN SCRIPT -->
                                <!---- INICIO---->
                                <input type="text" name="num1" class="form-control" id="num1" placeholder="USER">
                                 <input type="text" name="num2" class="form-control" id="num2" value="@box.domain.com" placeholder="Number 2">
                                <!---FIN-->
                                <!-- RESUTLADO PREVIEW -->
                                <p id="response"></p>
                                <!-- RESULDADO PREVIEW -->
                                
                                <input id="email" type="email" class="form-control" name="email" value="{{ old('email') }}" required autofocus>

                                @if ($errors->has('email'))
                                    <span class="help-block">
                                        <strong>{{ $errors->first('email') }}</strong>
                                    </span>
                                @endif
                            </div>
                        </div>

                        <div class="form-group{{ $errors->has('password') ? ' has-error' : '' }}">
                            <label for="password" class="col-md-4 control-label">{{ __('Password') }}</label>

                            <div class="col-md-6">
                                <input id="password" type="password" class="form-control" name="password" required>

                                @if ($errors->has('password'))
                                    <span class="help-block">
                                        <strong>{{ $errors->first('password') }}</strong>
                                    </span>
                                @endif
                            </div>
                        </div>

                        <div class="form-group">
                            <div class="col-md-6 col-md-offset-4">
                                <label class="checkbox">
                                    <input type="checkbox" name="remember" {{ old('remember') ? 'checked' : '' }}> {{ __('Remember Me') }}
                                </label>
                            </div>
                        </div>

                        <div class="form-group">
                            <div class="col-md-8 col-md-offset-4">
                                <button type="submit" onclick="concatme()" class="btn btn-primary">
                                    {{ __('Login') }}
                                </button>

                                @if (Eventy::filter('auth.password_reset_available', true))
                                    <a class="btn btn-link" href="{{ route('password.request') }}">
                                        {{ __('Forgot Your Password?') }}
                                    </a>
                                @endif
                            </div>
                        </div>
                    </form>
                    <p>Hola</p>

                    @action('login_form.after')
                </div>
            </div>
        </div>
    </div>
</div>
@endsection

Source: Laravel

Leave a Reply