how to take input as password in javascript promt box [duplicate]

匿名 (未验证) 提交于 2019-12-03 10:24:21

问题:

This question already has an answer here:

i want to take input password in java script prompt box but it only take input as string which is visible now how i can take input password in same text field. is there any way to change this text field from input type text to password without div

this is what i have already tried

prompt("enter password"); 

here is example

can any one suggest me how i can do this using j query or java script

回答1:

No, you can't.

The popup is browser controlled and can't be changed.

you can use javascript dialog box for it

HTML CODE

<div id="dialog" title="Basic dialog">     <input type="password" size="25" /> </div> 

JAVASCRIPT CODE

 $( "#dialog" ).dialog(); 

DEMO



回答2:

prompt is native browser functionality, and therefore not very flexible. Unfortunately, you cannot mask the input from a prompt.

Alternatively, you can use the input element with the password type:

<input type="password" size="25" /> 

And show this in a custom modal window. An input element with the type="password" attribute set, will automatically mask the entered characters. On how to embed this in a modal, there are many possibilities. If you are using jQuery, you might want to consider using jQuery UI for this: http://jqueryui.com/dialog/



标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!