4

사용자가 999-99-9999 형식으로 ssn을 입력 할 수 있도록 마스크를 제공하려고합니다. masked 입력 플러그인 from digital bush을 사용하려고했습니다. 크롬과 사파리에서는 정상적으로 작동하지만 안드로이드에서는 작동하지 않습니다.android2.3.3에서 jquery가있는 ssn 마스크

문제점 : 숫자를 입력 할 때, 123까지 괜찮습니다. 다음 2 자리를 입력하면 순서가 바뀝니다. 예 : 123-45를 입력하면 123-54로 표시되며 각 분리 기호에 대해이 문제가 계속됩니다. 예 : 123-45-6789를 입력하면 123-56-8974로 표시됩니다.

아래와 같이 키 누르기와 키 입력을 처리하기 위해 자신의 코드를 작성하려고했지만 여전히 동일한 문제가 발생했습니다. 어떤 사람이 안드로이드에 대한 입력 마스킹에 성공 했습니까? 대안은 무엇입니까? 내가의 keyup에 키 스트로크 (keystroke)에 따라 입력을 마스킹에 사용되는 코드 여기

<!DOCTYPE html> 
<html> 
<head> 
    <meta charset="utf-8"> 
    <meta name="viewport" content="width=device-width, initial-scale=1"> 
    <title> test ground</title> 

    <!-- JQuery specific --> 
    <script type="text/javascript" src="libs/jQuery/jQuery.min.js" ></script> 
    <script type="text/javascript" src="libs/jQuery/mobile/jquery.mobile.min.js"></script> 
    <link rel="stylesheet" href="libs/jQuery/mobile/jquery.mobile.min.css" /> 
    <script src="javascript/jquery.maskedinput-1.3.js" type="text/javascript" charset="utf-8"></script> 

    <!-- Application specific --> 
    <script type="text/javascript"> 
    $(document).bind('mobileinit',function(){ 
    // $.mobile.page.prototype.options.addBackBtn = true; 
    // $.mobile.page.prototype.options.backBtnText = "Previous"; 
    // $.mobile.page.prototype.options.backBtnTheme = "b"; 
    }); 

    $("[data-role='page']").live("pageshow", function(event) {   
     $("#primaryssn").mask("999-99-9999"); 
    }); 

    </script> 

</head> 

<body> 

<!-- ################### PAGE: launchpage ################### --> 
<div data-role="page" id="launchpage"> 
    <div id="header" data-role="header" data-position="fixed" >  
     <div id="headerlogo" > </div> 
     <h1 class="appTitle" >My App</h1> 
    </div> 

    <div data-role="content" > 
     <div class="content-primary"> 
      <p> Welcome to my app </p> <br/> 
     </div> 

     <!-- Primary SSN --> 
     <div data-role="none"> 
      <label name="lblprimaryssn" for="primaryssn" > SSN</label> 
      <input type="text" name="primaryssn" id="primaryssn" value="" /> 
      <span class="error" id="primaryssnerror"> Please enter your SSN as (999-99-9999) </span> 
     </div> 
     <br/> 

    </div><!-- /content --> 
</div><!-- /launch page --> 

</body> 
</html> 

됩니다 : 여기

코드 로컬 링크 전체 HTML입니다

// _v is value passed in on keyup in this input field 
// _d indicates if the key is a backspace to delete character 
var setSSN = function (_v, _d){ 
    var v = $.trim(_v); 

    if (!_d){ 
     if (v.length <= 3) { 
      var validformat1=/^\d{1,3}$/ ; 
      if (validformat1.test(v)) { 
       if (v.length == 3) v = v + '-'; 
       return v; 
      } 
     } 
     else if (v.length >3 && v.length <= 6) { 
      var validformat2=/^\d{3}\-\d{0,2}$/ ; 
      if (validformat2.test(v)) { 
       if (v.length == 6) v = v + '-'; 
       return v; 
      } 
     } 
     else { 
      var validformat3=/^\d{3}\-\d{2}\-\d{0,4}$/ ; 
      if (validformat3.test(v)) { 
       if (v.length == 6) v = v + '-'; 
       return v; 
      } 
     } 

     v = v.substring(0,v.length-1);   
     return v; 
    } 
    else { 
     if (3 == v.length || 6 == v.length) { 
      v = v.substring(0,v.length-1); 
     } 
    } 
    return v; 
} 
+0

동일한 문제가 있습니다. 솔루션을 찾을 수 없었습니다. – pdusen

답변

0

당신은 원하는 경우 사용할 수있는 문자를 숨기기

<input type="password"> 
0

이 문제는 마스크 된 입력 jquery에서 수정되었습니다. 플러그인. 최신 버전으로 업데이트하면이 문제가 해결됩니다.