2

I want to add a custom price filed just like the price field which can be seen when we add new products.

I can add a field like this

$fieldset->addField('price', 'text', array(
          'label'     => Mage::helper('menu')->__('Price'),
          'class'     => 'required-entry',
          'required'  => true,
          'name'      => 'price',
      ));

But I don't know how to validate it to take only numeric values. Can anyone help me please?

Or is their any other field type in magento that takes only numeric value?

5

Add class name validate-number

$fieldset->addField('price', 'text', array(
          'label'     => Mage::helper('menu')->__('Price'),
          'class'     => 'required-entry validate-number',
          'required'  => true,
          'name'      => 'price',
      ));
  • validate-not-negative-number for value >= 0 and validate-greater-than-zero for value > 0 – Nalin Savaliya Apr 10 '17 at 7:34

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.