I try to overwrite rules.js from vendor/Magento_Ui/web/js/lib/validation/rules.js in my custom theme but it dosen't work. I found this solution but it's not working for me : Magento 2 How to extend rules.js to add custom validation rules?

Does anyone have any idea if it's other method to overwrite rule.js file?

  • 1
    Did you remove static content and deploy again? – Khoa TruongDinh Jan 9 '17 at 10:41
  • yes. so the step should be: create a empty Magento_Ui folder in my custom theme, in design/frontendand/Package/themename and then in app/code/Package/themename/Magento_Ui/web/js/lib/validation/rules.js? – Alin Lupoiu Jan 9 '17 at 10:45
  • can i use any package name? i mean sould i put my file in any module and then create there a themename folder? – Alin Lupoiu Jan 9 '17 at 10:47
  • Did you clear Magento cache and Browser cache? – Khoa TruongDinh Jan 9 '17 at 10:49
  • yes. but the step i follow it's correct? – Alin Lupoiu Jan 9 '17 at 10:50

In your case, you need to create a custom theme. You should read more here: http://devdocs.magento.com/guides/v2.1/frontend-dev-guide/themes/theme-create.html

Put the validation rule in your custom theme with following path:


enter image description here

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.