Javascript form validation error
<pre><code>&lt;html&gt;
&lt;head&gt;
&lt;title&gt; Form Validation &lt;/title&gt;
&lt;style type="text/css"&gt;
fieldset { width: 280px; padding: 6px; }
label { float: left; width: 100px; font: 12px Arial; padding: 5px; }
input { margin-bottom: 5px; }
&lt;/style&gt;
&lt;/head&gt;

&lt;body&gt;
&lt;form id="inputForm" onsubmit="return validateForm();" action="#"&gt;
&lt;fieldset&gt;
    &lt;label&gt;First Name:&lt;/label&gt;&lt;input type="text" name="first_name" /&gt;&lt;br /&gt;
    &lt;label&gt;Surname:&lt;/label&gt;&lt;input type="text" name="surname" /&gt;&lt;br /&gt;
    &lt;label&gt;Postcode:&lt;/label&gt;&lt;input type="text" name="postcode" /&gt;&lt;br /&gt;
    &lt;label&gt;Email:&lt;/label&gt;&lt;input type="text" name="email" /&gt;&lt;br /&gt;
    &lt;input type="submit" name="submit" value="Send form" /&gt;
    &lt;input type="reset" name="reset" value="Reset" /&gt;
&lt;/fieldset&gt;
&lt;/form&gt;


&lt;script type="text/javascript"&gt;
function validateForm() {
    var form = document.forms['inputForm'];
    var formats = {
        First_name: /^[a-z]+[\-`\s]?[a-z]+$/i, 
        Surname: /^[a-z]+[\-`\S]?[a-z]+$/i, 
        Postcode: /^\d{4}$/, 
        Email:/^w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,4})+$/ 
    };

    var elCount = form.elements.length;
    for(var i = 0; i &lt;elCount; i++) {
        var field = form.elements[i];
        if(field.type == 'text') {
            if(!formats[field.name].test(field.value)) {
                alert('Invalid '+field.name.replace('_', ' '));
                field.focus();
                return false;
            }
    }
}
}
&lt;/script&gt;
&lt;/body&gt;
&lt;/html&gt;
</code></pre>

<p>Hey guys trying to figure out why the code is giving me a error:underfinded formats[fields.Name] but its has been defined. Its just a simple form so I am not sure what I am doing wrong. Sorry for the basic question but I have been looking over it multiple time and can't see it. Cheers again.</p>
