Magento WizardWelcome to the Number 1 Magento Hosting website.

Contact the site  Make Money

Remove Validation from Phone Number Field on Magento Checkout

 Add to Favourites  
(+2 rating, 4 votes)
Loading ... Loading ...

If you’re looking to remove the validation of telephone number (or the whole field completely) from the Magento checkout process, look no further.  I’ve read that quite a few people have had some difficultly in removing this field – not only because sometimes it is difficult to find the correct template, but moreso because Magento tries to validate this field when the Continue button is pressed on the checkout – so even if you manually remove the field, you cannot progress onto the next stage of the checkout!

Until now. 

Simply navigate to the file app/code/core/mage/customer/model/address/abstract.php and find the phrase “getTelephone” and you should comment out the code around this area, like so:

1
2
3
/*if (!Zend_Validate::is($this->getTelephone(), 'NotEmpty')) {
            $errors[] = $helper->__('Please enter telephone.');
        }*/

Similarly, to remove the actual field itself, go to app/design/frontend/default/default/template/checkout/onepage/billing.phtml and app/design/frontend/default/default/template/customer/address/edit.phtml and remove the…

1
<span class="required">*</span>

…or just delete the whole field! If you are doing the former, it’ll look something like this:

1
2
3
4
5
6
7
8
9
10
<li><div class="input-box">
                <label for="billing:postcode"><?php echo $this->__('Zip/Postal Code') ?> <span class="required">*</span></label><br />
                <input type="text" title="<?php echo $this->__('Zip/Postal Code') ?>" name="billing[postcode]" id="billing:postcode" value="<?php echo $this->htmlEscape($this->getAddress()->getPostcode()) ?>" class="validate-zip-international required-entry input-text" /></div>
                <div class="input-box">
                    <label for="billing:country_id"><?php echo $this->__('Country') ?> <span class="required">*</span></label><br />
                    <?php echo $this->getCountryHtmlSelect('billing') ?></div></li>
            <li><div class="input-box">
                <label for="billing:telephone"><?php echo $this->__('Telephone') ?> </label><br/>
                <input type="text" name="billing[telephone]" value="<?php echo $this->htmlEscape($this->getAddress()->getTelephone()) ?>" title="<?php echo $this->__('Telephone') ?>" class="input-text" id="billing:telephone" /></div>
                </li>

Good luck!

  • Digg
  • del.icio.us
  • Facebook
  • Google
  • LinkedIn
  • Live
  • Reddit
  • StumbleUpon
  • Technorati
  • TwitThis

about the author

    This article was written by Sam Davis on November 28, 2008.
    Computing over a glass of Grenache Shiraz... again!
    Sam is the Editor of Blasted Thing. Contact Us

related articles

 One Page Checkout (Guest Customer) - Video Guide
 Change Credit/Debit Card name in Magento
 One Page Checkout (Logged In Customer) - Video Guide
 Show Product Description on Magento Shopping Cart page
 Insecure or non-secure pages on the Magento Checkout

comments

12 Responses to “Remove Validation from Phone Number Field on Magento Checkout”

  1. Prashant on January 16th, 2009

    Very handy tip, thanks.

  2. jonny on March 14th, 2009

    For non-Windoze users the paths above are not case sensitive so:
    app/code/core/mage/customer/model/address/abstract.php
    should be:
    /app/code/core/Mage/Customer/Model/Address/Abstract.php
    Thanks

  3. Rick Stock on June 18th, 2009

    Hi nice post – very useful, definitely got me on the right track.

    One small thing – note that to make this work I also had to remove the class “required entry” from the actual address input field (the one just below the span mentioned here)…

  4. ricky on July 8th, 2009

    Thanks , this saved me quite a bit of time!

  5. Vijay Thummar on September 21st, 2009

    How can we remove this validation by custom module? not changing in core code?

    Thanks,
    Vijay Thummar

  6. Mohammad Tareq on November 10th, 2009

    Hi ,

    I am using Zend Forms
    I have dynamic validation.
    Trying to remove dynamic validation using the function

    $elements->removeValidator(‘ele_4af42ceac7810′);

    but its failing, not able to remove the validation, above field is having ‘Email’ Validation

    Plz help.

    Thanks
    mohammad Tareque

  7. Stanislav Kirilov on January 12th, 2010

    Thank you very much for the tip!

  8. maideen on March 31st, 2010

    it does not work for me

  9. Stiepan on April 7th, 2010

    Thanks for this very clear synthesis of the many confuse forum posts about the subject!
    Magento 1.4 users: the path to the default theme is base/default, not default/default; you have to adapt the above instructions accordingly.

  10. kev on June 28th, 2010

    Great help you have given me there. Thanks alot!

  11. dan on July 30th, 2010

    HEY thanks for this info but what about trying to remove validation when adding a customer manually trough the admin panel? Any ideas?
    Thanks again

  12. Chandigarh Flowers on September 17th, 2010

    thnks dude .. it is gr8 help for me.. keep helping us like this.. thanks

Leave a Reply




Spam protection by WP Captcha-Free


Make “Ship to This Address” Default in Magento Checkout

  • Sponsored Ads

  • Magento Themes
    • Terry: GoMage Feed Pro: http://www.gomage.com/extensions/gomage-feed-pro.html A product feed is a data f...
  • Recent Tweets

    同じ商品属性を持つ商品を関連商品として表示するエクステンション。使用する属性は自由なので同じ色、同じメーカーなど幅広く使えそう。http://t.co/gqKmwG4g 【木村】

    @astroboysoup Yep Magento :D hooking into Drupal and also stand-alone :D also any/all PHP template systems etc

    RT @magento: The Magento REST API: A Better Way to Integrate Business Applications http://t.co/24l3iBpz

    Agora bora trabalhar... Instalação de testes do #Magento... E leitura da documentação de suporte... HOJE TO EMPOLGADO!!!

    Needed #Magento #Developers at #Ahmedabad location. http://t.co/O5PqNszs #Magento #PHP #Mysql #Jobs #Ahmedabad