There are only six validation available for product attributes

  1. validate-number (Decimal Number)
  2. validate-digits (Integer Number)
  3. validate-email (Email)
  4. validate-url (URL)
  5. validate-alpha (Letters)
  6. validate-alphanum (Letters (a-z, A-Z) or Numbers (0-9))

I follow this link and add new(Value Greater than 0) validation to product attribute with the upgradeData script.

But it uses backend class for validate attribute value and validate value at the time of saving attribute. But I want JS validation which should working on tab key.

Have anyone an idea about custom JS validation on product attribute?

  • is your js customisation need for the frontend or for the backend, are you able to describe how you'd be using this js validation you want? Commented May 14, 2020 at 15:16

2 Answers 2


You have to write js validation functions like validate-email and other functions you mentioned. You can write your custom funtion in rules.js by overriding it in this way:

Vendor file :


Override file in custom theme :


There is already a function for value greater than 0:


You do not need to create custom validation for greater than zero as default magento already has that validation class. you can see in Product Add/Edit form > Advanced Pricing > Tire Price Qty Box. It does not allow value less than zero. For more information check this file


Your Answer

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

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