I’m trying to make a validation SKU of this product, showing an alert message. Before, I had the same problem in another situation.
<?php foreach($dvdLists as $key => $dvdList) { ?>
<p class="sku-validator-dvd" style="visibility:hidden;"><?= $dvdList->sku ?></p>
<?php } ?>
I tried to do the same solution with each function but doesn’t work. I need to get each SKU product to make a comparison with the SKU input. Doing this that way I can only get the first one. The second forward doesn’t work.
$('#save_product').click(function(e){
var skuInput = $.trim($('#sku').val());
if(skuInput === $('.sku-validator-dvd').text()) {
alert('This sku already exists');
}
});