Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I hide the password entered in a JavaScript dialog prompt with asterisk characters?

How can I hide the password entered by a user in a dialog prompt in JavaScript? For example, using something like this:

function ConfirmIt()
{
    var control4 = '<%=HiddenDelete.ClientID%>';
    if (document.getElementById(control4).value == "True")
    {
        var x = prompt('Enter your Password ')
        var control = '<%=HiddenField2.ClientID%>';
        if (x !== "") {
            document.getElementById(control).value = x;
        }
        else {
            document.getElementById(control).value = "0";
        }
    }
    else
    {
        alert("No Permission");
    }
}

I would like that when e.g. 12345 is entered it appears like ***** or ..... in the dialogue box. After that I want to select the password in a hiddenfield. Can anyone suggest how I can do this or provide some example code?

like image 856
Lima Avatar asked Oct 24 '25 00:10

Lima


1 Answers

Simple option is make the filed as password type

<input type="password" name="pwd">

It is better and easy to use Jquery Popup window or Dialog box if you are looking for a popup type window which will support with the password fields.

If you really want to stick into prompt then try this

like image 183
Arunprasanth K V Avatar answered Oct 26 '25 22:10

Arunprasanth K V



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!