I am building the magento site named www.bookslab.in. I want to remove the alert message "Above field is mandatory". It appears when users clicks on ADD TO CART button without checking the zipcode which is mandatory for every users. I want to remove this alert message because it does not need when user know that the Zipcode field is mandatory. I am attaching the screenshot for better understanding. I had added the cod.phtml code & updated my screenshot image to understand better.



$msgData = Mage::helper('netgo_cod')->getConfigData(); 
if($msgData['zip_status'] == 1){
<div class="input-box">
    <div class="z-btn">
        <label>Zip Code : </label><input type="text" placeholder="Enter your pincode" value="" name="cod" class="product-custom-option required-entry" id="cod" size="29" style='color:black; font-size:12px'>
        <button type="button" onclick="checkCOD();" name="zip-check" title="Check" class="button" id="zip-check"><span><span>Check</span></span></button>
    <div id="cod_msg"></div>

    function checkCOD(){
             var zipcode;
        var cod = $('cod').value;
        if(cod == ''){
            $('cod_msg').update('<span class="cod-error"><?php echo $msgData['emp_msg']; ?></span>');
            $('cod_msg').update('<img src="<?php echo Mage::getBaseUrl( Mage_Core_Model_Store::URL_TYPE_WEB, true ).'media/cod/img/ajax-loader-2.gif';?>">'); 
            new Ajax.Request('<?php echo Mage::getBaseUrl().'netgo/cod/check';?>', {
                parameters: {zipcode: cod}, 
                onSuccess: function(transport) {
                    var response = transport.responseText || "no response text";

                    if(response.search('Delivery of the books not available')!=-1)
                                          jQuery('.btn-cart').attr('disabled', 'disabled'); 


                onFailure: function() { alert('Something went wrong...'); }
<?php } ?>

enter image description here


You can use setTimeOut jQuery function to hide the message after it appears to users.

    jQuery('.btn-cart, #zip-check').click(function(){
        setTimeout(function() {
        }, 5000);

Here 5000 is the time in milliseconds, it defines 5 seconds, you can set it as per your requirements.

  • Okzz i will check your method & get back to you Feb 26 '17 at 13:10
  • In which file i have to add this code & on which line Feb 27 '17 at 11:33
  • You can put this code in app\design\frontend\rwd\default\template\catalog\product\view\addtocart.phtml Feb 27 '17 at 12:08
  • Okzz i will check Feb 27 '17 at 18:30
  • Thank you @Jaimin that works for me & sorry for the late reply Mar 13 '17 at 7:50

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.