jeudi 3 mars 2016

jQuery Validation Plugin on dynamic fields

I'm using the jQuery Validation Plugin(jqueryvalidation.org) on my Laravel 5.1 project.

The user first makes a GET request to chose a number($number) of input he wants. The range is from 0-10.

After that the form builds up:

{!! form::open(['method'=>'POST','route' => ['some.route']]) !!}
    @for($add = 0; $add < $number; $add++ )
        @include('part.addMember')
    @endfor
{!! Form::submit('Submit') !!}
{!! Form::close() !!}

part.addMember:

{!! Form::text("first_name[$add]",null) !!}
{!! Form::text("second_name[$add]", null) !!}
{!! Form::text("last_name[$add]", null) !!}
{!! Form::select("gender[$add]", 
['female' => 'Female', 'male' => 'Male', 'other' => 'Other']) 
!!}
{!! Form::date("birth_date[$add]", null) !!}

How would I validate it using the Plugin? Is it even possible? I know you can add fields using JS.



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire