パスワード フィールドに「パスワード」と書かれた透かしが必要です。
これが私のコードです:
jquery:
$(document).ready(function() {
var watermark = 'Password';
//init, set watermark text and class
$('#input_pwd').val(watermark).addClass('watermark');
//if blur and no value inside, set watermark text and class again.
$('#input_pwd').blur(function(){
if ($(this).val().length == 0){
$(this).val(watermark).addClass('watermark');
}
});
//if focus and text is watermrk, set it to empty and remove the watermark class
$('#input_pwd').focus(function(){
if ($(this).val() == watermark){
$(this).val('').removeClass('watermark');
}
});
});
html:
<input class="ui_input" id="input_pwd" type="password" name="pass" id="pass" style="height:25px; width:250px; font-size:14px;" required />
私のjsfiddle: ここをクリック
編集: 私は jquery を好みます :)
編集: 私たちの兄弟であるコンラッド・ガジナは、私が探していたものをくれましたが、皆さんの努力に感謝します!