I am building my first ASP.net MVC application (not my first jQuery & jQuery Validation plugin application), and I am having a terrible time performing the client side validation with the validation plugin. Does anyone know if there is a problem using the plugin with jQuery-1.3.2.min that comes with VS 2008?
My code is as follows:
var v = $("#frmAccount").validate({
rules: {
txtAccount: { minLength: 5,required: true },
txtFName: "required",
txtLName: "required"
},
message: {
txtAccount: {
required: "Account Number is required.",
minLength: jQuery.format("Account Number must be {0} or more charaters.")
},
txtFName: "First Name is required.",
txtLName: "Last Name is required.",
}
}); //validate
$("#cmd").click(function() {
if (v.form()) {
$("#frmAccount").submit();
}
});
............................
<form method="post" action="/Home/checkAccount" id="frmAccount">
<fieldset>
<legend>Account Information</legend>
<p>
<br />
<label for="txtAccount">Account Number:</label>
<br />
<input id="txtAccount" name="txtAccount" type="text" value="" />
<br />
<label for="txtFName">First Name:</label>
<br />
<input id="txtFName" name="txtFName" type="text" value="" />
<br />
<label for="txtLName">Last Name:</label>
<br />
<input id="txtLName" name="txtLName" type="text" value="" />
<br />
<label for="txtLName">Email:</label>
<br />
<input id="txtEmail" name="txtEmail" type="text" value="" />
</p>
<p>
<input type="button" id="cmd" name="cmd" value="Add" />
</p>
</fieldset>
</form>
When I try to submit the blank form, it returns the default "this field is required" next to the account, fname, & lname fields, but if I input any data into the fields I get various results.
I've tried to just perform the basic validate function (not returning the validate object to the v variable), but that produced similar results.
Have I just overlooked something silly here?