Jump to content

Prevent Po Box Shipping?


drillsar

Recommended Posts

Can this be done in newest version? Where is this file located?

For anyone looking to do this, this is the solution I finally came up with.

<input type="text" class="form-control" name="address1" id="address1" value="{if isset($smarty.post.address1)}{$smarty.post.address1}{/if}" title="Please enter a valid street address, we do not except P.O. Box addresses" pattern="^(?! *(#\d+|([bB][oO][Xx]|[Bb][Ii][Nn])[-. /\\]?\d+|.*[pP][ .]? ?[Oo0][-. /\\]? *-?(([bB][oO][Xx]|[Bb][Ii][Nn])|b|(#|[Nn][Uu][Mm])?\d+)|[Pp]([Oo][Ss][Tt])? *([Oo]([Ff]{2}([Ii][Cc][Ee])?)?)? *(([bB][oO][Xx]|[Bb][Ii][Nn])|? *\d+|[Pp] *-?/?[Oo]? *-?[bB][oO][Xx]|[Pp][Oo][Ss][Tt] [Oo][Ff][Ff][Ii][Cc][Ee] ([bB][oO][Xx]|[Bb][Ii][Nn])|(([bB][oO][Xx]|[Bb][Ii][Nn])|[Bb]) *([Nn][Uu][Mm][Bb][Ee][Rr]|[Nn][Uu][Mm]|#)? *\d+|([Nn][Uu][Mm][Bb][Ee][Rr]|[Nn][Uu][Mm]|#) *\d+)).*"/>

Open up authentication.tpl and find the input fields with the id of "address1" (there should be two of them within the file) and replace them with the code provided above. From what I can tell that should be enough to validate against PO Box addresses inputted into the fiels. No additional code is required.

 

Below you will find the additions and what they do:

title="Please enter a valid street address, we do not except P.O. Box addresses" 

When you enter something into the field that doesn't match the validation criteria you will receive a message telling you to make sure your content is inputted in the correct format but by default it doesn't tell you what the correct format should be. Adding a title attribute will allow you to add content to the validation message that pops up giving the user an indication of why the form will not submit.

pattern="^(?! *(#\d+|([bB][oO][Xx]|[Bb][Ii][Nn])[-. /\\]?\d+|.*[pP][ .]? ?[Oo0][-. /\\]? *-?(([bB][oO][Xx]|[Bb][Ii][Nn])|b|(#|[Nn][Uu][Mm])?\d+)|[Pp]([Oo][Ss][Tt])? *([Oo]([Ff]{2}([Ii][Cc][Ee])?)?)? *(([bB][oO][Xx]|[Bb][Ii][Nn])|? *\d+|[Pp] *-?/?[Oo]? *-?[bB][oO][Xx]|[Pp][Oo][Ss][Tt] [Oo][Ff][Ff][Ii][Cc][Ee] ([bB][oO][Xx]|[Bb][Ii][Nn])|(([bB][oO][Xx]|[Bb][Ii][Nn])|[Bb]) *([Nn][Uu][Mm][Bb][Ee][Rr]|[Nn][Uu][Mm]|#)? *\d+|([Nn][Uu][Mm][Bb][Ee][Rr]|[Nn][Uu][Mm]|#) *\d+)).*"

The pattern attribute is what tells the input field what is valid and what is not. This pattern can be used to exclude PO boxes is some of the main text formats that people might us (POBOX, P.O box, po bin, etc). Adding this to any text based input field will allow you to make that form validate against PO boxes.

Link to comment
Share on other sites

  • 2 years later...

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...