I am using magento 2.1.7. I have added vat field to billing address form. I want to add custom field validation. i have added below code.
Added below validation to phtml file
But my custom validation not working. Magento required field validation is working fine. Can anyone help me.
-
Hi @Prashant , didd you found the solutionJaisa– Jaisa2018年07月12日 04:47:40 +00:00Commented Jul 12, 2018 at 4:47
-
@sri as per given answer i have override rules js file. add your custom validation to override js filePrashant Valanda– Prashant Valanda2018年07月12日 15:47:14 +00:00Commented Jul 12, 2018 at 15:47
1 Answer 1
Override rules.js using below code in my custom module
app/code/Test/Custom/view/frontend/requirejs-config.js
var config = {
"map": {
"*" : {
'Magento_Ui/js/lib/validation/rules' : 'Test_Custom/js/validation/rules'
}
}
};
created js file at app/code/Test/Custom/view/frontend/web/js/validation/rules.js
Run php bin/magento setup:static-content:deploy command.
-
great, it works! Haven't you found another way without override rules.js?LucScu– LucScu2018年08月06日 10:20:08 +00:00Commented Aug 6, 2018 at 10:20
-
There is mixin concept but that is not working in my case. Please try with mixinPrashant Valanda– Prashant Valanda2018年08月07日 06:25:17 +00:00Commented Aug 7, 2018 at 6:25
-
yes, i could try to override rules.js, thx very muchLucScu– LucScu2018年08月07日 16:51:08 +00:00Commented Aug 7, 2018 at 16:51
Explore related questions
See similar questions with these tags.