Posting in the Magento forums has been disabled pending the implementation of a new and improved forum solution which should better serve the community.

For new questions please post at magento.stackexchange.com, the community-run support site for the Magento community. We will be providing updates on the new forum solution soon. For questions or concerns please email community@magento.com.

Magento Forum

Validation for add to cart for negative value and zero
 
Lalgamba
Jr. Member
 
Total Posts:  3
Joined:  2009-12-23
 

20 I want to validate in the add to cart quantity when someone enter negative or zero value in the quantity. I know that magento by default take 1 value if someone entry negative or zero value. Anyone have any idea about this one.

 
Magento Community Magento Community
Magento Community
Magento Community
 
Lalgamba
Jr. Member
 
Total Posts:  3
Joined:  2009-12-23
 

There is no one that can solve this problem in magento forum?????????

 
Magento Community Magento Community
Magento Community
Magento Community
 
danivalentin
Jr. Member
 
Total Posts:  1
Joined:  2012-03-26
 

Maybe too late, but you just have to add a validate-greater-than-zero class to the field. All validation classes are available here: http://www.magentocommerce.com/wiki/5_-_modules_and_development/admin/xml_structure_for_admin_configurations

 
Magento Community Magento Community
Magento Community
Magento Community
 
MuniStavyah
Jr. Member
 
Total Posts:  1
Joined:  2012-12-25
 


Hi,
In Product details page we are having the quantity field, by default it accepts strings and negative numbers. we can fix this issue very easily just by adding class names.

app->design->frontend->default-> <your theme> ->template->catalog->product->view->addtocart.phtml
in line 33 you can see the text filed with id="qty", just add the following classes for that field
validate-greater-than-zero validate-number

You can see all the validation classes in
http://www.magentocommerce.com/wiki/5_-_modules_and_development/admin/xml_structure_for_admin_configurations

 
Magento Community Magento Community
Magento Community
Magento Community
Magento Community
Magento Community
Back to top