JSFiddle - React, Tailwind, and code Playground

HTML

<input type="text" value="4531" name="product_id" />
<input type="text" value="4532" name="product_id" />
<input type="hidden" value="4533" name="product_id" />
<input type="hidden" value="4533" name="product_id" />
<input type="hidden" value="4533" name="product_id" />
<button class='btnSubmit'>Submit</button>

JavaScript

$(".btnSubmit").click(function () {
    var errorCounterDupInput = 0;
    var product_ids = [];
    $("input[name='product_id']").each(function (i, el1) {
        var current_val = $(el1).val();
        console.log("current_val : " + current_val);
        if (current_val != "") {
            if(product_ids.indexOf(current_val) === -1){
                product_ids.push(current_val);
            } else {
                errorCounterDupInput++;
            }
        }
    });
    console.log(errorCounterDupInput);
});