1
MY .js文件:不工作jQuery驗證形式
//rounded corners
$(document).ready(function() {
$("#topbar").corner("bl br 5px");
$("#mainbar").corner("5px");
$("#sidebar").corner("5px");
$("#bottombar").corner("5px");
});
//form
$(document).ready(function(){
$("#commentForm").validate({
rules: {
FieldData0: {
required: true
},
FieldData1: {
required: true,
email: true
},
FieldData2: {
required: true
}
},
messages: {
FieldData0: {
required: "* Required"
},
FieldData1: {
required: "* Required",
minlength: "* 2 Characters Required."
}
}
});
})
我的.html文件:
<div id="mainbar">
<form id="commentForm" method="post" action="http://www.emailmeform.com/fid.php?formid=254816">
<h2>Contact Form</h2>
<p>
<label for="name">Your Name</label>
<input type="text" id="name" name="FieldData0" />
</p>
<p>
<label for="email">Your Email</label>
<input type="text" id="email" name="FieldData1" />
</p>
<p>
<label for="message">Your Message</label>
<textarea type="text" id="message" name="FieldData2"></textarea>
</p>
<p>
<input id="button" type="submit" value="Submit">
</p>
</form>
</div>
活生生的例子:
http://weedcl.zxq.net/form.html
你可以發佈演示網址嗎?爲什麼不把兩個初始化放在同一個$(document).ready()塊中? – 2010-01-23 15:09:09
我是jquery noob。我知道如何做到這一點,而不會像我在自定義js中看到的那樣破壞函數 – alexchenco 2010-01-23 15:21:16
,我看到你有很多初始化,「$(document).ready(function(){」and「$(function(){ 「是一樣的...只是選擇一個,把你所有的jQuery裏面... – Reigel 2010-01-23 15:25:51