Conflicting Javascript preventing form validation
<p>im trying to validate a form before its submitted to the database but something seems to be conflicting with it and its just sending anyway without any values</p>

<p><strong>heres my form:</strong></p>

<pre><code>&lt;form method="post" action="send.php" id="theform" name="theform"&gt;
&lt;input type="text" name="firstname" id="firstname" value="First Name" onFocus="this.value=''" class="yourinfo" &gt;&lt;br/&gt;
&lt;input type="text" name="lastname" id="lastname" value="Last Name" onFocus="this.value=''" class="yourinfo"&gt;&lt;br/&gt;
&lt;input type="text" name="email" id="email" value="Email Address" onFocus="this.value=''" class="yourinfo"&gt;&lt;br/&gt;
&lt;span style="color:#FFF; font-family:Arial, Helvetica, sans-serif; font-size:12px;"&gt;Ally McCoist will be sacked on&lt;/span&gt;
&lt;div id="datepicker"&gt;&lt;/div&gt;
&lt;input type="hidden" name="date" id="date"&gt;
&lt;input type="image" src="images/submit-button-small.png" name="submit" id="submit" value="submit" style="margin-top:10px; margin-left:-2px;" &gt;
&lt;/form&gt;
</code></pre>

<hr>

<p><strong>heres my validate javascript:</strong></p>

<pre><code>$(document).ready(function(){
// Place ID's of all required fields here.
required = ["firstname", "lastname", "email"];
// If using an ID other than #email or #error then replace it here
email = $("#email");
errornotice = $("#error");
// The text to show up within a field when it is incorrect
emptyerror = "Please fill out this field.";
emailerror = "Please enter a valid e-mail.";

$("#theform").submit(function(e){                

    //Validate required fields
    for (i=0;i&lt;required.length;i++) {
        var input = $('#'+required[i]);
        if ((input.val() == "") || (input.val() == emptyerror)) {
            input.addClass("needsfilled");
            input.val(emptyerror);
            errornotice.fadeIn(750);
        } else {
            input.removeClass("needsfilled");
        }
    }
    // Validate the e-mail.
    if (!/^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/.test(email.val())) {
        email.addClass("needsfilled");
        email.val(emailerror);
    }

    //if any inputs on the page have the class 'needsfilled' the form will not submit
    if ($(":input").hasClass("needsfilled")) {
         e.preventDefault();
    } else {
         errornotice.hide();
    }


});

// Clears any fields in the form when the user clicks on them
$(":input").focus(function(){       
   if ($(this).hasClass("needsfilled") ) {
        $(this).val("");
        $(this).removeClass("needsfilled");
   }
});
}); 
</code></pre>

<hr>

<p><strong>i also have this javascript on the page fore my jquery UI datepicker which i think might be causing the problem</strong></p>

<pre><code>&lt;script&gt;
        $(function() {
$("#datepicker").datepicker({
    altField: '#date'
});

$('#submit').click(function() {
    $('#output').html($('form').serialize());
});
</code></pre>

<p>});
    </p>

<p>fingers crossed one of you can see something that might fix this problem</p>
