<?php
for ($i=0; $i < $total_vehicles; $i++) {
$id=$edtVehicle[$i]->id;
$chasis=$edtVehicle[$i]->chasis;
?>
//HTML CONTENT "novs[][]" want to validate it using jquery validation
<div class="controls content contold">
<input type="hidden" name="hid_novs[]" value="<?php echo $id;?>">
<input type="text" name="novs[<?php echo $id;?>][]" id="novs_<?php echo $i;?>" value="<?php echo $chasis;?>">
<button type="button" class="removebtn"><i class="fa fa-times"></i></button>
<span class="span_error"></span>
</div>
<?php
}
?>
JQUERY VALIDATION
$("#add_user_form").validate({
"novs[]":{ required:true, },
messages: { "novs[]":{ required : "Please fill this value" }, }
});
I Solved it with this way, it's solved now thank you.
$("input[name^='novs_'" ).each(function(){
$(this).rules("add", {
required: true,
messages: {
required: "Fill a valid value"
}
});
});
Hope fully this will helps you to get id
$('.removebtn').click(function() {
//console.log( $(this).siblings('.removebtn'));
//console.log($(this).siblings("input").attr('id'));
var found = false;
$(this).siblings("input").each(function (i, name) {
// Check if field is empty or not
console.log(name);
if (!found && jQuery(name).val() == '') {
alert('Please enter value')
found = true;
};
});
return !found;
});