Jump to content

UK Postcode Issues


Recommended Posts

Hi,

 

I am having issue with the postcode validation within the customer registration stage.

 

I have changed the postcode validation option in the back office so that a customer can submit a postcode of any type but whenever a postcode is inserted, a red X is shown in the box as if it is invalid. The customer is still able to submit their address but the box shows as if it has an incorrect input.]

 

We have postcodes such as 

 

WA1 1AA

WW11 1AA

W1 1AA

 

As i say, I have removed all validation from within the back office but somewhere, there is still something happening because when I type an american zip code in, it shows as being correct.

 

The postcode is required and the validation box is empty within Location > Countries > (My selected country)

 

Kind Regards

 

Chris

post-1053057-0-14073500-1440406014_thumb.png

post-1053057-0-71248200-1440406014_thumb.png

Link to comment
Share on other sites

I have just found within the validate.js file the following code and removed it.

function validate_isPostCode(s, pattern, iso_code)
{
	if (typeof iso_code === 'undefined' || iso_code == '')
		iso_code = '[A-Z]{2}';
	if (typeof(pattern) == 'undefined' || pattern.length == 0)
		pattern = '[a-z 0-9-]+';
	else
	{
		var replacements = {
			' ': '(?: |)',
			'-': '(?:-|)',
			'N': '[0-9]',
			'L': '[a-zA-Z]',
			'C': iso_code
		};

		for (var new_value in replacements)
			pattern = pattern.split(new_value).join(replacements[new_value]);
	}
	var reg = new RegExp('^' + pattern + '$');
	return reg.test(s);
}

Now I have removed it the red X doesn't show.

 

Does anyone know if removing this will cause problems elsewhere?

 

Kind Regards

 

Chris

Link to comment
Share on other sites

  • 3 weeks later...

I changed the file themes/theme-default/address.tpl at line 103. I deleted "validate"

 
original file:
<input class="is_required validate form-control" data-validate="{$address_validation.$field_name.validate}" type="text" id="postcode" name="postcode" value="{if isset($smarty.post.postcode)}{$smarty.post.postcode}{else}{if isset($address->postcode)}{$address->postcode|escape:'html':'UTF-8'}{/if}{/if}" />

 

changed file

<input class="is_required form-control" data-validate="{$address_validation.$field_name.validate}" type="text" id="postcode" name="postcode" value="{if isset($smarty.post.postcode)}{$smarty.post.postcode}{else}{if isset($address->postcode)}{$address->postcode|escape:'html':'UTF-8'}{/if}{/if}" />

Link to comment
Share on other sites

  • 1 month later...
×
×
  • Create New...