Skip to content

Instantly share code, notes, and snippets.

@SheriSmith
Created November 26, 2015 00:25
Show Gist options
  • Save SheriSmith/f750fb86168dadf666e3 to your computer and use it in GitHub Desktop.
Save SheriSmith/f750fb86168dadf666e3 to your computer and use it in GitHub Desktop.
Validation.add('validate-for-pobox','The shipping address must be a physical address. PO Boxes are allowed for billing only.',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)){
return false;
}
return true;
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment