I´m a bit confused here. The thing is that I have an asp.net textbox that I want to tab to the next textbox when maxlength is true and the user does not hit certain keys. My asp.net code is like this:
<asp:TextBox ID="txbTransferBanknumber" Style="width: 50px;" MaxLength="4"
Visible="true" runat="server" autocomplete="off" onkeyup="autoTabNextTextBox(this,'txbTransferLedger')" CssClass="AutoTabFill" />
my autoTabNextTextBox function looks like this:
function autoTabNextTextBox(sender, nextTextBox) {
var keyCode = (event.which) ? event.which : event.keyCode
var mylength = $(sender).val().length;
var maxlength = $(sender).attr('maxLength');
if((keyCode != 37) && (keyCode != 39))
{
if ((keyCode != 8) && (keyCode != 16))
{
if (mylength == maxlength)
{
$('.nextTextBox').focus();
//nextTextBox.focus();
}
}
}
}
How do I pass the parameter nextTextBox to .focus() ?
Assuming that you have a ClientIdMode of Static (meaning the id of the output HTML element is
txbTransferLedger) then you just need to include the nextTextBox parameter as part of the selector (as opposed to the stringnextTextBoxwhich you are currently using):Update: If you cannot use a ClientIdMode of Static and therefore don’t have full control over the generated ids of the input elements then another option is to use a class selector instead. Give each input element a unique class name (this can be in addition to any existing classes you are using) e.g.:
Then pass the the class name you want (
TransferLedgerin this example) into theautoTabNextTextBoxfunction instead of the ID. You can then use a class selector as follows: