Jump to content

Php specific number check


Marshalltx

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

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.