我有这个标签表单,有四个不同的文本字段和两个类似的提交按钮。顾客使用该表格登录他们的图书馆帐户。当有人尝试使用一个选项卡中的文本字段登录,不成功,并使用另一个选项卡中的文本字段继续登录时,会出现问题。当顾客尝试双向登录时,不会清除上次不成功尝试的信息。在两个不同的登录区域之间来回切换时,如何清除用户输入的信息?
function tabSwitch(new_tab, new_content) {
document.getElementById('ldap_login').style.display='none';
document.getElementById('barcode_login').style.display='none';
document.getElementById(new_content).style.display='block';
document.getElementById('ldap_tab').className='';
document.getElementById('barcode_tab').className='';
document.getElementById(new_tab).className='active';
}
<div id=" " class="tabbed_area">
<form name="patform" method="POST">
<ul id="tabs">
<li><a href="javascript:tabSwitch('ldap_tab', 'ldap_login');" id="ldap_tab" class="active">Active students, faculty, and staff</a></li>
<li><a href="javascript:tabSwitch('barcode_tab', 'barcode_login');" id="barcode_tab">Community, alumni, emeriti, and others</a></li>
</ul>
<div id="ldap_login" class="content">
Clemson Username: <br />
<input type="text" name="extpatid" id="extpatid" value="" size="20" maxlength="40">
Your iRoar, Blackboard, etc., username <br/>
Password:* <br />
<input name="extpatpw" id="extpatpw" type="text" value="" size="20" maxlength="40">
*Passwords cannot contain the special characters < and >. <br /><br />
<input type="image" src="/screens/pat_submit.gif" border="0" name="" value="submit">
</div>
<div id="barcode_login" class="content">
Last Name: <br />
<input type="text" name="name" id="name" value="" size="20" maxlength="40">
For example, type "Smith." <br />
Barcode: <br />
<input name="code" id="code" type="text" value="" size="20" maxlength="40">
Type the letter plus 10 digit number located on the back of your TigerOne ID card (or 9 digit number plus "1" for old library cards).<br /><br />
<input type="image" src="/screens/pat_submit.gif" border="0" name="" value="submit">
</div>
</form>
</div>
答案 0 :(得分:0)
将2个标签包装到自己的表单中。这样,提交只会从各自的选项卡中获取输入,并忽略其他选项卡上的任何内容。
<div id="ldap_login" class="content">
<form>
Clemson Username: <br />
<input type="text" name="extpatid" id="extpatid" value="" size="20" maxlength="40">
Your iRoar, Blackboard, etc., username <br/>
Password:* <br />
<input name="extpatpw" id="extpatpw" type="text" value="" size="20" maxlength="40">
*Passwords cannot contain the special characters < and >. <br /><br />
<input type="image" src="/screens/pat_submit.gif" border="0" name="" value="submit">
</form>
</div>
等。