validation using jquery
Posted
by fusion
on Stack Overflow
See other posts from Stack Overflow
or by fusion
Published on 2010-04-05T22:43:41Z
Indexed on
2010/04/05
23:03 UTC
Read the original article
Hit count: 348
i'm trying to validate an html page using jquery, but nothing happens. it's a simple page, yet the textboxes aren't validated.
this is the code:
<link rel="stylesheet" type="text/css" href="style.css" />
<script type="text/javascript" src="~/jquery.js/"></script>
<script type="text/javascript" src="~/jquery-validate/jquery.validate.js/"></script>
<script type="text/javascript">
$(document).ready(function(){
var validator = $("#submitForm").validate({
debug: true,
rules: {
author: "required",
quote: "required"
},
messages: {
author: "Name of Author required"
quote: "Please enter Quote"
},
errorPlacement: function(error, element) {
error.appendTo( element.parent().top() );
}
);
});
</script>
<body>
<div class="container">
<div class="center_div">
<h2>Submit Your Quote</h2>
<fieldset>
<form id="submitForm" action="qinsert.php" method="post">
<div class="error" style="display:none"></div>
<div class="field">
<label>Author: </label>
<input name="author" type="text" class="required" minLength=3>
<span class="error"></span>
</div><br />
<div class="field">
<label>Quote: </label>
<textarea name="quote" cols=22 class="required" minLength=5></textarea>
<span class="error"></span>
<br />
</div>
<input id="button1" type="submit" value="Submit" class="submit" /><br />
<input id="button2" type="reset" value="Reset" />
</form>
</fieldset>
</div>
</div>
what is wrong with the code? thank you!
© Stack Overflow or respective owner