2

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.

enter image description here

Added below validation to phtml file

enter image description here

But my custom validation not working. Magento required field validation is working fine. Can anyone help me.

asked Feb 26, 2018 at 14:45
2
  • Hi @Prashant , didd you found the solution Commented Jul 12, 2018 at 4:47
  • @sri as per given answer i have override rules js file. add your custom validation to override js file Commented Jul 12, 2018 at 15:47

1 Answer 1

3

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.

answered Feb 27, 2018 at 16:01
3
  • great, it works! Haven't you found another way without override rules.js? Commented Aug 6, 2018 at 10:20
  • There is mixin concept but that is not working in my case. Please try with mixin Commented Aug 7, 2018 at 6:25
  • yes, i could try to override rules.js, thx very much Commented Aug 7, 2018 at 16:51

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.