I have 3 asp.net text box and an html input botton, when enter is pressed in any of the above text boxes input button click event must be fired.My code is
<li class="right2">
<asp:TextBox ID="txtPassportNumber" ClientIDMode="Static" MaxLength="20" CssClass="textEntry"
runat="server"></asp:TextBox>
</li>
<li class="left"><label>First Name</label></li>
<li class="right2">
<asp:TextBox ID="txtFName" ClientIDMode="Static" MaxLength="20" CssClass="textEntry" runat="server"></asp:TextBox>
</li>
<li class="left"><label>Last Name</label></li>
<li class="right2">
<asp:TextBox ID="txtLName" ClientIDMode="Static" MaxLength="20" CssClass="textEntry" runat="server"></asp:TextBox>
</li>
<input type="button" id="btnSearch" clientidmode="Static" class="search button formbutton"
value="Search" validationgroup="SearchPanelSubmit" runat="server" />
I have write the following jquery code
$(document).ready(function () {
if ($('#txtPassportNumber').keypress(function (e) {
if (e.keyCode == 13)
$('#btnBasicSearch').click();
}));
}
I have used multiple if 's in jquery code but the button is not working when more then 1 text box has some text in it.How to handle enter event for multiple text boxes ?