phplaravel-5jsvalidation

Validate Laravel form in real time using laravel-jsvalidation


I am using laravel-jsvalidation to validate forms on client side but the plugin validate the form after submit.

How can I change it to a real-time validation while user is inputting data?

Calling plugin:

<script type="text/javascript" src="{{ asset('vendor/jsvalidation/js/jsvalidation.js')}}"></script>
{!! $validator->selector('#review-form')  !!}

Form:

    <form action="{{action('GoToTheController')}}" method="POST" id="review-form">
        <div class="form-group"><input type="text" class="fullName" name="fullName">
        </div>
    </form>

Controller:

    $validator = JsValidator::make( ['fullName'=> 'required']);

    return view('create')->with('validator', $validator);

Solution

  • In bootstrap.php under the plugin(laravel-jsvalidation) folder I added these lines so it works fine by clicking on input elements.

        onfocusout: function (element) {
                if (!this.checkable(element)) {
                    this.element(element);
                }
            }
    

    or you can make a copy of the file, add the above lines into it and use it.