Combine two field in email field

  javascript, laravel, php


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.


<div class="container">
    <div class="row">
        <div class="col-md-8 col-md-offset-2">


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


                    <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;
                                <!-- 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="" placeholder="Number 2">
                                <!-- 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>

                        <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>

                        <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') }}

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

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


Source: Laravel

Leave a Reply