JSFiddle - React, Tailwind, and code Playground
HTML
<form>
<input type="checkbox" name="produit_type[]" value="奢侈品与配饰">奢侈品与配饰
<input type="checkbox" name="produit_type[]" value="女士时尚">女士时尚
<input type="checkbox" name="produit_type[]" value="男士时尚">男士时尚
<input type="checkbox" name="produit_type[]" value="美妆与护肤">美妆与护肤
<input type="checkbox" name="produit_type[]" value="儿童">儿童
<input type="checkbox" name="produit_type[]" value="内衣">内衣
<input type="checkbox" name="produit_type[]" value="aa">aa
<input type="submit" value="submit">
</form>
JavaScript
var checkbox_required = $('input[type="checkbox"]');
checkbox_required.prop('required', true);
checkbox_required.on('click', function(){
if (checkbox_required.is(':checked'))
{
checkbox_required.prop('required', false);
}
else
{
checkbox_required.prop('required', true);
}
});