Javascript Postcode Validation
<p>Ok so, I'm currently working on a site that has a store finder and the store finder works great with both town names and post codes but the post code has to have a space in it. 
E.g. 'RG1 7UE' and won't work without the space E.g. 'RG17UE'</p>

<p>So i've got a bit of JS on the text box (see below) to adjust the spacing on the postcode and that works great, the only problem now is that the JS will put a space in if you type a town or city in the box.  Does anyone have an idea how i can get around this so that i can use the same text input box for both city and postcode?</p>

<p>Thanks,</p>

<p>Martyn</p>

<pre><code>&lt;input type="text" placeholder="Enter a postcode or town/city..." value="&lt;?php echo $_POST['text'] ?&gt;"  id="address" name="text" class="locator_inputform px192 search-box" onblur="this.value = this.value.replace(/ /g,'').replace( /^(.{2,4})(.{3})(.*)$/, '$1 $2' )"&gt;
</code></pre>
