2014-10-30 1 views
0

어떻게 2 자리 뒤에 다음 필드에 자동 포커스를 얻을 수 있습니까? 여기 다음 필드에서 Jquery 자동 포커스

나를 위해 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

http://stackoverflow.com/questions/15595652/focus-next-input-once-reached-maxlength-value – JB06

답변

0

을이 시도 :

$('#personalDetailMobilePhoneAreaInput').keyup(function(){ 

    var maxLength = $(this).attr('maxlength'); 
    var currLength = $(this).val().length;   

    if(currLength >= maxLength) 
     $(this).siblings('input').focus(); 
}); 

이 직접 시도해보십시오 http://jsfiddle.net/4kjh44Lm/

관련 문제