Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Validation.add('validate-pobox','We cannot ship to your P.O. Please check the button to ship to a different address.',function(field_value) {
// setup a regex var for pretty much every possibility of PO box...
var regex = /[P|p]*(OST|ost)*\.*\s*[O|o|0]*(ffice|FFICE)*\.*\s*[B|b][O|o|0][X|x]/;
// if the field_value contains PO Box
if(field_value.match(regex))
{
if (document.getElementById('billing:use_for_shipping_yes').checked == true)
{
return false;
}
return true;
}
else
{
if(!field_value.match(regex))
{
return true;
}
}
});
Validation.add('validate-pobox2','We cannot ship to your P.O. Please check the button to ship to a different address.',function(field_value) {
// setup a regex var for pretty much every possibility of PO box...
var regex2 = /[P|p]*(OST|ost)*\.*\s*[O|o|0]*(ffice|FFICE)*\.*\s*[B|b][O|o|0][X|x]/;
// if the field_value contains PO Box
if(field_value.match(regex2))
{
if (document.getElementById('billing:use_for_shipping_yes').checked == true)
{
return false;
}
return true;
}
else
{
if(!field_value.match(regex2))
{
return true;
}
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.