我有以下代碼來執行下面顯示的SubmitForm驗證。當我單擊AddressListing div標記並調用驗證函數時,它僅對businessname字段執行驗證,但不對其他剩餘feilds.Only商業名稱字段將以紅色突出顯示,但不會顯示其他行爲。我使用下面的jQuery插件驗證領域http://jquery.bassistance.de/validate/jquery.validate.js使用jquery validate插件進行表單驗證的問題
example.html的
<fieldset id="fieldset1"> <legend>Registration Details:</legend>
<form id="SubmitForm">
Name of business:<br/>
<input size="30" type="text" id="businessname" class="required" /><br/>
Zipcode:<br>
<input size="30" type="text" id="zipcode" class="required zipcode"/><br>
Telephone:<br/>
<input size="30" type="text" id="telephone" class="required phone" /><br/>
Email:<br/>
<input size="30" type="text" id="email" class="required email"/>
</fieldset>
<br/>
Your email is your User Name:<br/>
<input size="30" type="text" id="username" class="required"/><br/>
Choose Password:<br/>
<input size="30" type="text" id="pass" class="required password" class="required"/><br/>
Retype Password:<br/>
<input size="30" type="text" id="pass1" equalTo="#pass"/><br/>
<input id="Addresslisting" type="image" src="images/Submit.png" align="left" />
</form>
</feildset>
Example.js
$(document).ready(function() {
$("#Addresslisting").click(function() {
$("#addresslistingform").validate();
});
});
Example.css
label { width: 10em; float: left; }
label.error {
color: red; padding:8px 200px 0px 0px; vertical-align: top; float:right;
background:url("unchecked.gif") no-repeat 120px 0px;
}
input.error {border:1px solid red;}
input.errorlist {margin:0; color: red; margin-bottom:10px;}
#fieldset1
{
border: 1px solid #1f76c8;
width: 500px;
margin:5px;
padding:10px 15px 5px 15px;
}
我的表單的Id是SubmitForm我怎麼能寫submitForm,S和F都在大寫 – mahesh 2010-10-07 11:38:29
錯誤...所以我的代碼示例。你嘗試過其中之一嗎? – Gazler 2010-10-07 11:41:03
對不起,謝謝你的答覆,這實際上是我的錯誤 – mahesh 2010-10-07 11:44:42