Email Validation Problem
<p>I am Validating email address of a User. But problem appeared when i call that function and form is submitted without validating email address. Please tell me whats wrong with that code.</p>

<pre><code>function validateEmail(fld) {
var error="";
var tfld = trim(fld.value);                   
var emailFilter = /^[^@]+@[^@.]+\.[^@]*\w\w$/ ;
var illegalChars= /[\(\)\&lt;\&gt;\,\;\:\\\"\[\]]/ ;
if (fld.value == "") {
    fld.style.background = 'Pink';
    error = "You didn't enter an email address.\n";
} else if (!emailFilter.test(tfld)) {         
    fld.style.background = 'Pink';
    error = "Please enter a valid email address.\n";
} else if (fld.value.match(illegalChars)) {
    fld.style.background = 'Pink';
    error = "The email address contains illegal characters.\n";
} else {
    fld.style.background = 'White';
}
return error; }
</code></pre>
