2013-07-21 5 views
2

텍스트 및 암호 입력 필드에 대한 자리 표시자를 갖고 싶습니다. 나는 Internet Explorer 외에 모든 것을 할 수있다. 어떻게 할 수 있습니까? 어쩌면 jquery일까요? 특히 비밀번호에 대해서는 자리 표시자가 "비밀번호"라고 말하고 싶습니다. 그리고 입력이 클릭되면 그 안에있는 텍스트가 암호 텍스트로 나타납니다. 감사! :)Internet Explorer 용 자리 표시자를 수정하는 방법은 무엇입니까?

+0

가능한 중복 미리 채워진 경우 사업부를 숨길 지 여부 값이 있는지 확인해야합니다 [ Internet Explorer 용 입력 자리 표시 자] (http://stackoverflow.com/questions/5522164/input-placeholders-for-internet-explorer) –

+0

* password *는 유용한 자리 표시자가 아니며 악용하려는 것으로 보입니다 '

답변

1

IE9 +는 자리 표시자를 지원한다고 가정하지만 이는 사실이 아닙니다. 자리 표시자를 '가장하는'몇 가지 방법이 있습니다. IE에서 자리 표시 자 모양/느낌을 갖는 가장 좋은 방법은 표시하려는 텍스트가 들어있는 입력 상자 (입력 상자가 투명 함) 뒤에 div를 추가하는 jquery 함수를 만드는 것입니다. 그런 다음 입력 또는 데이터가 표시 될 때 A 표시 : 없음 div 또는 불투명 입력 상자.

다른 사람들은 텍스트를 입력 필드에 넣지 만 유효성 검사를 통해 고통을 느낄 수 있으며 비밀번호 필드를 발견 할 수 있습니다.

뭔가 같은 :

// Check browser type so we don't mess with other browsers that do this right 
if (BrowserDetect.browser === 'Explorer') { 
    // Find all placeholders 
    $('[placeholder]').each(function(_index, _this) { 
     var $this = $(this); 
     var id = this.id; 
     var thisValue = $this.val(); 
     var value = $this.attr('placeholder'); 
     var $element = $('#' + id + '_ph'); 
     if ($element.length === 0) { 
      // Add placeholder if no input you want to add it even if value in case they remove value 
      $this.attr('placeholder', ''); 
      // Add the div (make sure you style ie_placeholder_fix 
      // class with correct positioning etc) 
      $('<div id="' + id + '_ph" class="ie_placeholder_fix">' + value + '</div>').insertAfter($this); 
     } 
     //Maybe you want to hide if it has a value? 
     if (thisValue) { $element.hide(); } else { $element.show(); } 
     $this.blur(checkForInput); 
    }); 
} 

당신은 그들 만이 값 (즉, 편집 가능한 양식)의

관련 문제