1
你好,當我得到一些驗證錯誤,如果我重置我的表單錯誤仍然在頁面上我怎麼能重置錯誤以及輸入字段。請幫助我在這如何重置驗證jsp頁面按下重置按鈕時顯示的錯誤
剛剛javascript我該怎麼寫在resetForm()方法?
<form action="RegisterServlet" method="post" name="Register" id="signup" onSubmit="return validate()">
<table>
<tr>
<td>First Name* : </td>
<td><input type="text" name="txtFname" id="fname" maxlength="30" onKeyup="capitalize(this)"/><br/>
<span id="errorFirstNameMissing" style="display:none;"><font color="red">*Please provide your first name.</font></span>
<span id="errorFirstNameInValid" style="display:none;"><font color="red">*Please provide a valid first name.</font></span>
</td>
</tr>
<tr>
<td>Last Name* : </td>
<td><input type="text" name="txtLname" id="lname" maxlength="30" onKeyup="capitalize(this)"/><br/>
<span id="errorLastNameMissing" style="display:none;"><font color="red">*Please provide your Last name.</font></span>
<span id="errorLastNameInValid" style="display:none;"><font color="red">*Please provide a valid Last name.</font></span>
</td>
</tr>
<tr>
<td>Gender* : </td>
<td><select name = "txtGender" id="gender">
<option value="unknown">Select your Gender</option>
<option value="Male">Male</option>
<option value="Female">Female</option>
</select><br/>
<span id="errorMissingGender" style="display:none;"><font color="red">*Please select a Gender.</font></span>
</td>
</tr>
<tr>
<td>Category* : </td>
<td><select name = "txtCategory" id="category">
<option value="unknown">Select your Category</option>
<option value="Affiliate">Affiliate</option>
<option value="Client">Client</option>
<option value="Admin">Admin</option>
</select><br/>
<span id="errorMissingCategory" style="display:none;"><font color="red">*Please select a Category.</font></span>
</td>
</tr>
<tr>
<td><script type="text/javascript"
src="js/Calendar.js"></script>
</td>
</tr>
<tr>
<td>Age :</td>
<td><input type=text name=txtAge id="ageId" readonly style="width: 20px;background-color:#D0D0D0;border:none"/>yrs.</td>
</tr>
<tr>
<td>Address* : </td>
<td><textarea rows="5" name="txtAddr" id="addr" cols="30"></textarea><br/>
<span id="errorMissingAddress" style="display:none;"><font color="red">*Please provide a valid Address.</font></span>
</td>
</tr>
<tr>
<td>State* :</td>
<td> <select onchange="print_city('city',this.selectedIndex);" id="state" name ="txtState"></select><br/>
<span id="errorMissingState" style="display:none;"><font color="red">*Please select a state.</font></span>
</td>
</tr>
<tr>
<td>City* :</td> <td><select name ="txtCity" id ="city"></select>
<script language="javascript">print_state("state");</script><br/>
<span id="errorMissingCity" style="display:none;"><font color="red">*Please select a city.</font></span>
</td>
</tr>
<tr>
<td>Pincode* : </td>
<td><input type="text" name="txtPin" id="pin"/><br/>
<span id="errorMissingPinCode" style="display:none;"><font color="red">*Please provide your Pincode.</font></span>
<span id="errorPinCodeInvalid" style="display:none;"><font color="red">*Please provide a valid Pincode.</font></span>
</td>
</tr>
<tr>
<td>e-Mail* : </td>
<td><input type="text" name="txtEmail" id="email"/><br/>
<span id="errorMissingEmail" style="display:none;"><font color="red">*Please provide your emailId.</font></span>
<span id="errorEmailInvalid" style="display:none;"><font color="red">*Please provide a valid emailId.</font></span>
</td>
</tr>
<tr>
<td>Contact Number : </td>
<td><input type="text" name="txtStd" id="std" maxlength="6" style="width: 40px"/>-<input type="text" name="txtPhone" id="phone" maxlength="8"/><br/>
<span id="errorStdCodeInvalid" style="visibility:hidden;"><font color="red">*Please provide a valid std code.</font></span>
<span id="errorPhoneNoInvalid" style="visibility:hidden;"><font color="red">*Please provide a valid contact no.</font></span>
</td>
</tr>
<tr>
<td>Mobile Number* : </td>
<td>+91-<input type="text" name="txtMobile" id="mobile" maxlength="10"/><br/>
<span id="errorMissingMobileNo" style="display:none;"><font color="red">*Please provide your mobile number.</font></span>
<span id="errorMobileNoInvalid" style="display:none;"><font color="red">*Please provide a valid mobile number.</font></span>
</td>
</tr>
</table>
<br/>
<p><font color="red">Note: All the fields marked with * are mandatory.</font></p>
<p><input type="checkbox" name="chkAgree" onclick="EnableSubmit(this)" /><font color="green"> I here by declare that the above data entered by me is true to my knowledge.</font> </p>
<br/>
<div class="style2">
<table>
<tr>
<td><button type="submit" id="submit" disabled style="width: 80px;height: 40px">Submit</button></td>
<td><div class="divider"></div></td>
<td><button type="reset" style="width: 80px;height: 40px" onClick="resetForm()">Reset</button></td>
</tr>
</table>
</div>
</form>