开发者

Display default value in password field as plaintext

开发者 https://www.devze.com 2023-03-06 01:52 出处:网络
Is it possible to display the default text in a password field as plaintext ?开发者_如何学JAVA Using below code the textfield value is displayed as \"**\" instead of \"Password\"

Is it possible to display the default text in a password field as plaintext ?

开发者_如何学JAVA

Using below code the textfield value is displayed as "**" instead of "Password"

Thanks

<div id="fnameDiv" data-role="fieldcontain">    
    <input id="password" name="password" type="password" value="Password"/>
</div>


Live Example: 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();

This might be Related: change type of input field with jQuery

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号