How to trigger default magento validation in custom module in magneto 2

by Sri   Last Updated January 19, 2018 13:09 PM

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

Answers 1

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}'>

For fore info please follow this links

Navin Bhudiya
Navin Bhudiya
January 19, 2018 12:38 PM

Related Questions

Ajax:Product Review in magento 2

Updated January 02, 2018 11:09 AM