Marshalltx Posted August 5, 2011 Share Posted August 5, 2011 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)(); } //]]> Quote Link to comment https://forums.phpfreaks.com/topic/243907-php-specific-number-check/ Share on other sites More sharing options...
trq Posted August 5, 2011 Share Posted August 5, 2011 You are aware that that isn't php? Quote Link to comment https://forums.phpfreaks.com/topic/243907-php-specific-number-check/#findComment-1252470 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.