Validate cloned dynamic fields. Parsley and laravel 5.1

2

I have a form in which I can add, in my case, order lines. This is done with JQuery, cloning the entire line.  I use laravel 5.1 for the backend and for the client side I am occupying a JavaScript library of forms called parsley. At the time of validation by the server there is no problem, but at the time of doing it by client-side with parsley I can not make my elements can validate them separately. I do not know if I can understand. Attached photos to get an idea.

Add line code

$("#addRow").on("click",function(e){    
    e.preventDefault();
     e.stopPropagation();   

$("#tabla tr:last").clone().find("input, select").val('').each(function() {
  }).end().appendTo("#tabla"); 

  });

Form view code

{!!Form::open(['route'=>'venta.store', 'id'=>'forma','method'=>'POST','data-parsley-validate'=>'parsley-validate'])!!} 

@include('venta.forms.venta')

{!!Form::close()!!}

input blade element

<td width="17%">
<input type="text" class="form-control" id="cantidad" name="vtcanp[]" required /> 

</td>

The problem is that when I generate more than one line and I want to validate these new lines and put some value, it still gives me problems that there is no value being that I add one as it appears in the photo I put. I hope you understand

    
asked by Andrés Gómez Vega 19.10.2016 в 21:46
source

1 answer

-1

You can use regular expression in html. how are you using JavaScript I suppose you are using HTML.

for example look at this example ..

<form action="somefile.php">
    <input type="text" name="username" placeholder="Username" pattern="[a-z]{1,15}">
</form>

I leave you some links that look for to apply them in the web,

link

link

link

link

    
answered by 19.10.2016 в 22:25