I am trying to add the same message of pdf pages, Please enter a valid number in this field in another page of a custom module.
when the add to cart button is clicked without any value inside text box
here is the code I am trying:
<form data-role="tocart-form" action="<?php /* @escapeNotVerified */ echo $postParams['action']; ?>" method="post">
<input type="hidden" name="product" value="<?php /* @escapeNotVerified */ echo $postParams['data']['product']; ?>">
<input type="hidden" name="<?php /* @escapeNotVerified */ echo Action::PARAM_NAME_URL_ENCODED; ?>" value="<?php /* @escapeNotVerified */ echo $postParams['data'][Action::PARAM_NAME_URL_ENCODED]; ?>">
<?php echo $block->getBlockHtml('formkey')?>
<div class="add-to-cart-desktop">
<div class="grid-qty">
<label class="label" for="grid-item-<?php echo $_product->getId() ?>-qty"><?php /* @escapeNotVerified */ echo __('Qty') ?></label>
<span class="arrow-minus"></span>
<input type="number" min="1" name="qty" value="1" id="grid-item-<?php echo $_product->getId() ?>-qty" size="4" class="item-qty qty-input real-one" data-validate="{required-number:true,validate-item-quantity:{minAllowed:1,maxAllowed:10000}}" >
and here is the script for it:
<script type="text/x-magento-init">
{
"[data-role=tocart-form]": {
"Magento_Catalog/js/validate-product": {}
}
}
</script>
but I do not see any changes.
can you tell me what is wrong?