I have multiple dynamic dropdown i am validating it through jquery required validator. But issue is the dropdown is starting from 0 index so validation not working when Select is selected. I'm using the following code.
jQuery('form#add_form :input').each(function(){
jQuery(this).rules('add', {
required: function(element) {
if(element.type=='select') {
if(jQuery(this).children('option:selected').val() == '0')
{
return false;
}
else
{
return true;
}
} else
{
return true;
}
} });
});
Form tag :
{{Form::open(array('','method' => 'post','class'=>'add-form','id'=>'add_form')) }}
@foreach($parent_attrs as $pattr)
<div class="col-md-6">
<label>
{!! Form::select('product'.$pattr->id, $products, $pattr, ['class' => 'form-control']) !!}
</div>
@endforeach