I am trying to validate a form using jquery validate with PHP. I have done all this using google......I am new to the web development.The form is working absolutely fine in FF but the script is not wotking in IE 11..HELP ME...THANKS... The code is given below:
<script src="js/jquery-1.9.0.js"></script>
<script src="js/jquery.validate.min.js"></script>
<!-- jQuery Form Validation code -->
<script>
// When the browser is ready...
$function() {
// Setup form validation on the #register-form element
$("#register-form").validate({
// Specify the validation rules
rules: {
topic: "required",
detail: "required",
name: "required",
email: {
required: true,
email: true
},
},
// Specify the validation error messages
messages: {
topic: "Enter the subject for your suggestion",
detial: "Please enter your suggestion",
name: "Please enter your name. It will be kept hidden",
email: "Please enter a valid email address",
/* username: "Please enter a valid username",
password: {
required: "Please provide a password",
minlength: "Your password must be at least 5 characters long"
}*/
},
submitHandler: function(form) {
form.submit();
}
});
});
</script>
<table align="center" width="800px" border="1" class="table_css">
<?php echo $output; ?>
<!-- The form that will be parsed by jQuery before submit -->
<tr><td >Submit Your Suggestion</td></tr>
<tr><td>
<form action="add_topic.php" method="post" id="register-form" name="register-form" novalidate>
<div class="label">Subject</div><input type="text" id="topic" name="topic" value="<?php echo $topic; ?>" size="50"/><br />
<div class="label">Suggestion</div>
<textarea name="detail" cols="60" id="detail" rows="15" value="<?php echo $detail; ?>"></textarea><br />
<div class="label">Name</div><input type="text" id="name" name="name" value="<?php echo $name; ?>" size="30" /><br/>
<div class="label">Email</div><input type="text" id="email" name="email" value="<?php echo $email; ?>" size="30"/><br /><div style="margin-left:200px;"><input type="submit" name="submit" value="Submit" /><input type="reset" name="Submit2" value="Reset" /></div>
</form>
</td>
</tr>
</table>
Change the name of the submit button
<input type="submit" name="submit" value="Submit" />
to something other than submit.
<input type="submit" name="btnSubmit" value="Submit" />
I had the similar issue. I added the following code to set browser compatibility for Internet Explorer to make it run. Add the following code in <head>
tag.
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
It makes the script to work in IE11.
From another thread, it looks like IE doesn't handle excessive commas well. Try removing the comma after the email
properties in the messages and rules objects.
https://github.com/jquery-validation/jquery-validation/issues/2225 problems in version 1.18.0
a safe solution would be to install version 1.17.0 -> npm install jquery-validation@1.17.0 and check if the plugin really is with version 1.17.0