我試圖驗證使用jQuery的html頁面,但沒有任何反應。這是一個簡單的頁面,但文本框未經驗證。驗證使用jQuery
這是代碼:
<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>
什麼是錯的代碼?謝謝!
請參閱您的回覆帖子的評論以獲取腳本標記的進一步說明src屬性 – Tommy 2010-04-05 23:07:51