Question

I have created custom module for magento review module, Now All the functionalities works fine. But default magento validation is failed for Review form. Now, How do i trigger the dafault validation to my custom module

Was it helpful?

Solution

Just Add this data-hasrequired=" Required Fields" data-mage-init='{"validation":{}}' line to your form tag as show in below example and need to set validation class in input element like data-validate='{}'

<form id="test" name="test" method="post"  action="<?php echo $block->getUrl('test/index/test'); ?>" data-hasrequired="* Required Fields"  data-mage-init='{"validation":{}}'>
    <div class="input-box">
         <input name="name" id="name" title="<?php echo __('First name / last name'); ?>" value="" class="input-text required-entry" type="text" data-validate='{"required":true}'>
         </div>
    </form>

For fore info please follow this links http://inchoo.net/magento-2/validate-custom-form-in-magento-2/

Licensed under: CC-BY-SA with attribution
Not affiliated with magento.stackexchange
scroll top