<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	>
<channel>
	<title>Comments on: Javascript: check if a UK postcode is valid</title>
	<atom:link href="http://www.qodo.co.uk/blog/javascript-check-if-a-uk-postcode-is-valid/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.qodo.co.uk/blog/javascript-check-if-a-uk-postcode-is-valid/</link>
	<description>Home of Web Designer, Stewart Orr</description>
	<pubDate>Thu, 20 Nov 2008 09:37:17 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.6.3</generator>
		<item>
		<title>By: Simon</title>
		<link>http://www.qodo.co.uk/blog/javascript-check-if-a-uk-postcode-is-valid/#comment-284</link>
		<dc:creator>Simon</dc:creator>
		<pubDate>Mon, 18 Aug 2008 12:55:40 +0000</pubDate>
		<guid isPermaLink="false">http://www.qodo.co.uk/blog/javascript-check-if-a-uk-postcode-is-valid/#comment-284</guid>
		<description>To cater for the newer central london postcodes, the regex string used should be:

var postcodeRegEx = /[A-Z]{1,2}[0-9]{1,2}[A-Z]{0,1} ?[0-9][A-Z]{2}/i;</description>
		<content:encoded><![CDATA[<p>To cater for the newer central london postcodes, the regex string used should be:</p>
<p>var postcodeRegEx = /[A-Z]{1,2}[0-9]{1,2}[A-Z]{0,1} ?[0-9][A-Z]{2}/i;</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Stewart</title>
		<link>http://www.qodo.co.uk/blog/javascript-check-if-a-uk-postcode-is-valid/#comment-282</link>
		<dc:creator>Stewart</dc:creator>
		<pubDate>Mon, 28 Jul 2008 14:06:44 +0000</pubDate>
		<guid isPermaLink="false">http://www.qodo.co.uk/blog/javascript-check-if-a-uk-postcode-is-valid/#comment-282</guid>
		<description>Yes that is possible. It would probably be best to use this function along with some other javascript to achieve this. &lt;a href="/contact/" rel="nofollow"&gt;Contact me&lt;/a&gt; with an example of what you want to do and I'll see if I can help.</description>
		<content:encoded><![CDATA[<p>Yes that is possible. It would probably be best to use this function along with some other javascript to achieve this. <a href="/contact/" rel="nofollow">Contact me</a> with an example of what you want to do and I&#8217;ll see if I can help.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: techno-mole</title>
		<link>http://www.qodo.co.uk/blog/javascript-check-if-a-uk-postcode-is-valid/#comment-281</link>
		<dc:creator>techno-mole</dc:creator>
		<pubDate>Fri, 25 Jul 2008 20:31:06 +0000</pubDate>
		<guid isPermaLink="false">http://www.qodo.co.uk/blog/javascript-check-if-a-uk-postcode-is-valid/#comment-281</guid>
		<description>i wonder if you could help with something, basically i am wondering if the code could be adapted to not only check for a valid post code, but also check for a specific set of post codes, and display an alert.
so for example if you entered you post code into a form on a website, this script could be used by calling the function when a button is clicked, but could it also then throw out an alert saying what ever if it finds a particular post code, or the first part of a post code ? and how could that be done ?
cheers</description>
		<content:encoded><![CDATA[<p>i wonder if you could help with something, basically i am wondering if the code could be adapted to not only check for a valid post code, but also check for a specific set of post codes, and display an alert.<br />
so for example if you entered you post code into a form on a website, this script could be used by calling the function when a button is clicked, but could it also then throw out an alert saying what ever if it finds a particular post code, or the first part of a post code ? and how could that be done ?<br />
cheers</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Stewart</title>
		<link>http://www.qodo.co.uk/blog/javascript-check-if-a-uk-postcode-is-valid/#comment-257</link>
		<dc:creator>Stewart</dc:creator>
		<pubDate>Mon, 12 May 2008 17:26:26 +0000</pubDate>
		<guid isPermaLink="false">http://www.qodo.co.uk/blog/javascript-check-if-a-uk-postcode-is-valid/#comment-257</guid>
		<description>Hi Amir, you could change the regular expression to allow characters as well as numbers:

&lt;pre&gt;&lt;code&gt;
/* tests to see if string is in correct UK style postcode: AL1 1AB, BM1 5YZ etc. */
function isValidPostcode(p) {
	var postcodeRegEx = /[A-Z]{1,2}[&lt;strong&gt;A-Z&lt;/strong&gt;0-9]{1,2} ?[0-9][A-Z]{2}/i;
	return postcodeRegEx.test(p);
}

/*	formats a VALID postcode nicely: AB120XY -&gt; AB1 0XY */
function formatPostcode(p) {
	if (isValidPostcode(p)) {
		var postcodeRegEx = /(^[A-Z]{1,2}[&lt;strong&gt;A-Z&lt;/strong&gt;0-9]{1,2})([0-9][A-Z]{2}$)/i;
		return p.replace(postcodeRegEx,”$1 $2″);
	} else {
		return p;
	}
}
&lt;/code&gt;&lt;/pre&gt;</description>
		<content:encoded><![CDATA[<p>Hi Amir, you could change the regular expression to allow characters as well as numbers:</p>
<pre><code>
/* tests to see if string is in correct UK style postcode: AL1 1AB, BM1 5YZ etc. */
function isValidPostcode(p) {
	var postcodeRegEx = /[A-Z]{1,2}[<strong>A-Z</strong>0-9]{1,2} ?[0-9][A-Z]{2}/i;
	return postcodeRegEx.test(p);
}

/*	formats a VALID postcode nicely: AB120XY -> AB1 0XY */
function formatPostcode(p) {
	if (isValidPostcode(p)) {
		var postcodeRegEx = /(^[A-Z]{1,2}[<strong>A-Z</strong>0-9]{1,2})([0-9][A-Z]{2}$)/i;
		return p.replace(postcodeRegEx,”$1 $2″);
	} else {
		return p;
	}
}
</code></pre>
]]></content:encoded>
	</item>
	<item>
		<title>By: Amir</title>
		<link>http://www.qodo.co.uk/blog/javascript-check-if-a-uk-postcode-is-valid/#comment-256</link>
		<dc:creator>Amir</dc:creator>
		<pubDate>Mon, 12 May 2008 16:32:37 +0000</pubDate>
		<guid isPermaLink="false">http://www.qodo.co.uk/blog/javascript-check-if-a-uk-postcode-is-valid/#comment-256</guid>
		<description>Hi,

This has proven to be really useful to me.

Any suggestions on how to make the function "isValidPostcode" valid for the post code "GIR 0AA".

Obviously I can do an if/else statement, but I would be interested to see what you would do.</description>
		<content:encoded><![CDATA[<p>Hi,</p>
<p>This has proven to be really useful to me.</p>
<p>Any suggestions on how to make the function &#8220;isValidPostcode&#8221; valid for the post code &#8220;GIR 0AA&#8221;.</p>
<p>Obviously I can do an if/else statement, but I would be interested to see what you would do.</p>
]]></content:encoded>
	</item>
</channel>
</rss>
