1

我有这个带有四个不同文本字段和两个类似提交按钮的选项卡式表单。读者使用该表格登录他们的图书馆帐户。当有人尝试使用一个选项卡中的文本字段登录但不成功,然后继续使用另一个选项卡中的文本字段登录时,就会出现问题。当顾客尝试以两种方式登录时,他们最后一次不成功尝试的信息不会被清除。在两个不同的登录区域之间来回切换时,如何清除用户输入的信息?

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>
4

1 回答 1

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>

ETC..

于 2013-09-15T23:49:50.853 回答