Jump to content

Recommended Posts

Hello all,

 

Im trying to make a function in Php for my magento store, that allow the users to enter their Postal/Zip number to see if we can deliver in their area.

 

Basicly its a input field and when user press the button, an "alert" would popup with the message.

So far I can only make it work if users presses a number below 5000..

But I would like to be more specific with the numbers that should give the alert.

 

This is what I have created so far:

Perhaps someone can help me out....

//<![CDATA[

 

            var coShippingMethodForm = new VarienForm('shipping-zip-form');

 

            var countriesWithOptionalZip = <?php echo $this->helper('directory')->getCountriesWithOptionalZip(true) ?>;

            coShippingMethodForm.submit = function () {

                var country = $F('country');

                var optionalZip = false;

                for (i=0; i < countriesWithOptionalZip.length; i++) {

                    if (countriesWithOptionalZip == country) {

                        optionalZip = true;

                    }

                }

if(document.getElementById('postcode').value >5000){alert('We can not deliver in this area');return false;}

                if (optionalZip) {

                    $('postcode').removeClassName('required-entry');

                }

                else {

                    $('postcode').addClassName('required-entry');

                }

                return VarienForm.prototype.submit.bind(coShippingMethodForm)();

            }

        //]]>

Link to comment
https://forums.phpfreaks.com/topic/243907-php-specific-number-check/
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.