是否可以将密码字段中的默认文本显示为纯文本?
使用以下代码,文本字段值显示为“ * * ”而不是“密码”
由于
<div id="fnameDiv" data-role="fieldcontain">
<input id="password" name="password" type="password" value="Password"/>
</div>
答案 0 :(得分:2)
直播示例:http://jsfiddle.net/t4BQm/18/
HTML:
<div data-role="page" data-theme="b" id="jqm-home">
<div data-role="content">
<div id="fnameDiv" data-role="fieldcontain">
<label for="name">Password:</label>
<input id="password" name="password" type="password" placeholder="Password"/>
</div>
<div id="fnameDivHidden" class="hidden_div" data-role="fieldcontain">
<label for="name">Password:</label>
<input id="password_hidden" name="password_hidden" type="text"/>
</div>
<div data-role="fieldcontain">
<fieldset data-role="controlgroup" data-role="controlgroup" data-type="horizontal">
<legend>Display Password:</legend>
<input type="radio" name="show_password" id="no" value="no" checked="checked" />
<label for="no">No</label>
<input type="radio" name="show_password" id="yes" value="yes" />
<label for="yes">Yes</label>
</fieldset>
</div>
</div>
</div>
JS:
$('[name=show_password]').change(function() {
var show = $('input[name=show_password]:checked').val() == 'yes';
// toggle the password and the hidden text inputs
$('#password_hidden').val($('#password').val());
if(show) {
$('#fnameDivHidden').show();
$('#fnameDiv').hide();
} else {
$('#fnameDivHidden').hide();
$('#fnameDiv').show();
}
});
$('#fnameDivHidden').hide();