Skip to content

Password fields should be changed to text fields #8

@tjconcept

Description

@tjconcept

When using example on a password field, you just get a string of stars, not very usefull.

I've used this rather ugly code to change a password field to a text field, when the example text is shown:

$('form').on('blur','input[type="password"]',function(){
    if ($(this).val() === '') {
        $(this).replaceWith(function(){
            return $(this).clone(true).attr('type','text').val($(this).attr('title')).addClass('was-password').addClass('example');
        });
    }
}).on('focus','input.was-password',function(){
    $(this).replaceWith(function(){
        return $(this).clone(true).attr('type','password').val('').removeClass('was-password').removeClass('example').addClass('set-focus');
    });
    $('input.set-focus').focus().removeClass('set-focus');
})
$('input[type="password"]').replaceWith(function(){
    if ($(this).val() === $(this).attr('title')) {
        return $(this).clone(true).attr('type','text').addClass('was-password').addClass('example');
    } else {
        return $(this).clone(true);
    }
});

Think something similar should be implemented in core. The reason why I'm replacing the input rather than just changing the type attribute is due to some security rule preventing the transform.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions