2011-03-12 67 views
0

這是Labelify:http://www.kryogenix.org/code/browser/labelify/使用jQuery插件Labelify

基本上,它可以讓我把一個淺灰色的文字在我的文本框會選擇它們時會消失。

我只有兩個問題:

  • 我使用在具有這種標籤的字段中的jQuery UI的Datapicker,當我點擊我想要的日期,該字段顯示的日期,但仍灰色(輸入的文字應該顯示爲黑色)。
  • 對於有密碼的字段,有沒有辦法讓密碼看起來像是type = password的輸入,但要讓淺灰色的標籤顯示爲明文?當我嘗試標記密碼字段時,標籤顯示爲標籤的長度而不是純文本。

謝謝!

回答

0

我知道這個職位是舊的,但我需要Labelify做密碼字段,你所提到的,所以我說的這段代碼的if (!lookupval) { return; }代碼段後,這應該是在第51行。

// Crob -- I added this to add the ability for Labilify to handle password fields. 
    // This creates a separate text field that just shows the value of title from the password field 
    // When focus is placed on the field it is hidden and the real field is shown. When focus is lost 
    // off the real field the text field is shown if there wasn't anything typed into the real field. 
if ($(this).attr("type") === "password") 
{ 
    var newField = $('<input>').attr('type', 'text').attr('value', lookup(this).replace(/\n/g, '')) 
     .addClass("ui-input-text ui-body-c") 
     .data('passwordField', $(this).attr('id')) 
     .attr('id', 'PassHelper-' + $(this).attr('id')) 
     .focus(function() { $("#" + $(this).data('passwordField')).show().focus(); $(this).hide(); }); 
    $(this).blur(function() 
    { 
     if ($(this).val() == "") 
     { $(this).hide(); $('#PassHelper-' + $(this).attr('id')).show(); } 
    }); 
    $(this).after(newField); 
    $(this).hide(); 
}