Display the default value in the plaintext password field

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

Using the code below, the value of the text field is displayed as " ** " instead of "Password"

thank

<div id="fnameDiv" data-role="fieldcontain">    
    <input id="password" name="password" type="password" value="Password"/>
</div>
+3
source share
1 answer

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();

It could be related: change input field type using jQuery

+2
source

All Articles