I want to apply validation in input to no to add the same value again.
<input type="text" data-loop="1" class="form-control Item_1 Item" name="Item">
<input type="text" data-loop="1" class="form-control Item_2 Item" name="Item">
<input type="text" data-loop="1" class="form-control Item_3 Item" name="Item">
Here is the jQuery to handle this.
$('.TableBody').on('change', '.Item', function() {
var loop_id = $(this).data('loop');
var Item = $('.Item_'+loop_id).closest('.Item').val();
});
});
Any help would be highly appreciated.
Loop over the input files and use the values as keys:
(Pseudo code)
lookup = {}
for each([item_number, value])) {
if (lookup[value]) {
throw error ('Items ' + item_number + ' and ' + lookup[value] + ' are identical')
} else {
lookup[value] = item_number
}
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.