I am new in Magento field. can you buddy help me to make understand how "add to cart button" validation HTML filed can find and works .? I reached




/catalog/product/view.phtml in this folder what should I analyze to understand about "add to cart" button validation please tell me to step by step with folder and directory name.

1 Answer 1


Find Add to Cart Button HTML

<button type="button" title="Add to Cart" class="button btn-cart" onclick="productAddToCartForm.submit(this)"><span><span>Add to Cart</span></span></button>

onclick it will call

var productAddToCartForm = new VarienForm('product_addtocart_form'); // prototype VarienForm object.

productAddToCartForm.submit = function(button, url) {
    if (this.validator.validate()) {
        var form = this.form;
        var oldUrl = form.action;

        if (url) {
           form.action = url;
        var e = null;
        try {
        } catch (e) {
        this.form.action = oldUrl;
        if (e) {
            throw e;

        if (button && button != 'undefined') {
            button.disabled = true;

As you go through each input field of product_addtocart_form you will get validation class added into field.

get list of validation class on inchoo.

to find location of each HTML fields refer this answer.

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.