我怎样才能在2位数之后在下一个字段上进行自动对焦?
这是jquery,它不适合我 -
$("#personalDetailMobilePhoneAreaInput").keyup(function () {
if (this.value.length == this.maxLength) {
$(this).next(':input').focus();
}
});
@Html.TextBoxFor(m => m.CommunicationView.MobilePhone.Area, new { @id = "personalDetailMobilePhoneAreaInput", @class="customText wdt80 numericValue",type = "text",maxlength="2" })
@Html.ValidationMessageFor(m => m.CommunicationView.MobilePhone.Area)
@Html.TextBoxFor(m => m.CommunicationView.MobilePhone.Number, new { @id = "personalDetailMobilePhoneNumberInput", @class="customText wdt120 mrglft10 phnIE numericValue",type = "text",maxlength="8" })
@Html.ValidationMessageFor(m => m.CommunicationView.MobilePhone.Number)
答案 0 :(得分:0)
试试这个:
$('#personalDetailMobilePhoneAreaInput').keyup(function(){
var maxLength = $(this).attr('maxlength');
var currLength = $(this).val().length;
if(currLength >= maxLength)
$(this).siblings('input').focus();
});