[jQuery] [validate] validation works in firefox but not in IE
I have a form set up with the validator plugin (ver 1.2.1) and
jquery(1.2.2) and the whole thing works perfectly in firefox 3b4, but
when i fire up IE (any version) i get a alert box with the following
message: "Error: Expected Identifier, string or number". when i hit
debug IE throws me to the postalcode definition in the rules section,
and i can't figure out what might be going on here.
There is no other javascript on the page.
Thank you,
Ariel
my code follows:
<script src="lib/jquery.js" type="text/javascript"></script>
<script src="lib/jquery.validate.js" type="text/javascript"></script>
<script type="text/javascript">
jQuery.validator.addMethod("phone", function(value, element) {
return this.optional(element) || value.match(/^\d{3}-\d{3}-
\d{4}$/);
}, "Must be XXX-XXX-XXXX");
jQuery.validator.addMethod("zip", function(value, element) {
return this.optional(element) || value.match(/^((\d{5}-\d{4})|
(\d{5})|([a-z]\d[a-z]\s?\d[a-z]\d))$/i);
}, "US or Canadian postal code only");
$().ready(function(){
$("#leadForm").validate({
debug:true,
rules: {
firstname: "required",
lastname: "required",
phone: {
required: true,
phone: true,
},
postalcode: {
required:true,
zip: true
},
email: {
required:true,
email:true
}
},
messages: {
firstname: "required",
lastname: "required",
phone:{
required: "required",
phone: "XXX-XXX-XXXX"
},
postalcode:{
required: "required",
zip: "Zip, Zip+4, or Canadian"
},
email:{
required: "required",
email: "valid email required"
}
}
})
});
</script>
<style type="text/css">
#leadForm label.error{
color:#FF0000
}
</style>
<form action="<?php echo $_SERVER['PHP_SELF'];?>" method="post"
id="leadForm">
<table>
<tr>
<td><label for="firstname">First Name:</label></td><td><input
id="firstname" name="firstname" type="text" maxlength="20" /></td>
</tr>
<tr>
<td><label for="lastname">Last Name:</label></td><td><input
id="lastname" name="lastname" type="text" maxlength="20" /></td>
</tr>
<tr>
<td><label for="phone">Phone:</label></td><td><input id="phone"
name="phone" type="text" maxlength="20" /></td>
</tr>
<tr>
<td><label for="postalcode">Postal Code:</label></td><td><input
id="postalcode" name="postalcode" type="text" maxlength="10" /></td>
</tr>
<tr>
<td><label for="email">Email:</label></td><td><input id="email"
name="email" type="text" maxlength="80" /></td>
</tr>
<tr>
<td><label for="besttimetocall">Best Time To Call:</label></
td><td><select name="besttimetocall" id="besttimetocall"><option
value="1">Morning</option><option value="2">Afternoon</option><option
value="3">Evening</option></select></td>
</tr>
<tr>
<td></td><td><input type="submit" value="Submit" name="submit" /></
td>
</tr>
</table>
</form>