Jump to content

Zip code validation maximum characters


Recommended Posts

  • 2 weeks later...

alleen 6 character in postcode met nederlandse postcode validatie.

Stap1. verkort de postcode veld
In global.css(van je huidige theme) helemaal aan de einde van dit bestand plakken
global.css :

form#account-creation_form input.text#postcode{
width:4em;
}



Stap2. Maximaal 6 characters
in "authentication.tpl" (van je huidige theme) zoek dit code:

-- @ regel 144+/-

zoek :


{l s='Postal code / Zip code'}
               <input type="text" class="text" name="postcode" id="postcode" value="{if isset($smarty.post.postcode)}{$smarty.post.postcode}{/if}" />
*


en voeg bij input: maxlength="6"


{l s='Postal code / Zip code'}
               <input maxlength="6" type="text" class="text" name="postcode" id="postcode" value="{if isset($smarty.post.postcode)}{$smarty.post.postcode}{/if}" />
*



Stap 3. Valideer 4 nummers 2 letters

IN validation.php
vervang the huidige "static public function isPostCode($postcode)" functie met:

static public function isPostCode($postcode)
   {
       return preg_match('/^[1-9][\d]{3}\s?(?!(sa|sd|ss|SA|SD|SS))([a-eghj-npr-tv-xzA-EGHJ-NPR-TV-XZ]{2})$/ui', $postcode);
   }




MVG,
DutchCoding

Link to comment
Share on other sites

Een makkie :P


voor validatie:
in customer.php
ga naar line +/- 73

 protected     $fieldsRequired = array('lastname', 'passwd', 'firstname', 'email');




vervang met

 protected     $fieldsRequired = array('lastname', 'passwd', 'firstname', 'email','birthday');




En voor de sterretje:
in Authentication.tpl zoek regel +/- 100:


{l s='Birthday'}

-
                   {foreach from=$days item=day}
{$day|escape:'htmlall':'UTF-8'}  
                   {/foreach}

               {*
                   {l s='January'}
                   {l s='February'}
                   {l s='March'}
                   {l s='April'}
                   {l s='May'}
                   {l s='June'}
                   {l s='July'}
                   {l s='August'}
                   {l s='September'}
                   {l s='October'}
                   {l s='November'}
                   {l s='December'}
               *}

-
                   {foreach from=$months key=k item=month}
{l s="$month"} 
                   {/foreach}


-
                   {foreach from=$years item=year}
{$year|escape:'htmlall':'UTF-8'}  
                   {/foreach}




voeg net boven de " < /p>" tag de "*" toe:


{l s='Birthday'}

-
                   {foreach from=$days item=day}
{$day|escape:'htmlall':'UTF-8'}  
                   {/foreach}

               {*
                   {l s='January'}
                   {l s='February'}
                   {l s='March'}
                   {l s='April'}
                   {l s='May'}
                   {l s='June'}
                   {l s='July'}
                   {l s='August'}
                   {l s='September'}
                   {l s='October'}
                   {l s='November'}
                   {l s='December'}
               *}

-
                   {foreach from=$months key=k item=month}
{l s="$month"} 
                   {/foreach}


-
                   {foreach from=$years item=year}
{$year|escape:'htmlall':'UTF-8'}  
                   {/foreach}

*



En dan ben je klaar :)
mvg,
DutchCoding

Link to comment
Share on other sites

  • 5 years later...

alleen 6 character in postcode met nederlandse postcode validatie.

 

Stap1. verkort de postcode veld

In global.css(van je huidige theme) helemaal aan de einde van dit bestand plakken

global.css :

form#account-creation_form input.text#postcode{width:4em;}

Stap2. Maximaal 6 characters

in "authentication.tpl" (van je huidige theme) zoek dit code:

 

-- @ regel 144+/-

 

zoek :

<p class="required text">                <label for="postcode">{l s='Postal code / Zip code'}</label>                <input type="text" class="text" name="postcode" id="postcode" value="{if isset($smarty.post.postcode)}{$smarty.post.postcode}{/if}" />                <sup>*</sup>            </p>
en voeg bij input: maxlength="6"

 

<p class="required text">                <label for="postcode">{l s='Postal code / Zip code'}</label>                <input maxlength="6" type="text" class="text" name="postcode" id="postcode" value="{if isset($smarty.post.postcode)}{$smarty.post.postcode}{/if}" />                <sup>*</sup>            </p>

Stap 3. Valideer 4 nummers 2 letters

 

IN validation.php

vervang the huidige "static public function isPostCode($postcode)" functie met:

static public function isPostCode($postcode)    {        return preg_match('/^[1-9][\d]{3}\s?(?!(sa|sd|ss|SA|SD|SS))([a-eghj-npr-tv-xzA-EGHJ-NPR-TV-XZ]{2})$/ui', $postcode);    }

 

MVG,

DutchCoding

 

This SOLVED my problem in PS 1.6 and I do not even speak the same language :)

 

Without maxlength="5" users can input 6+ characters (12345-6789 which is technically correct in the US) and it will cause the uspscarrier module to fail to show USPS as an option for shipping. This fixed it.

 

Thank You!

Link to comment
Share on other sites

×
×
  • Create New...