javascript - 启用自动完成的输入类型密码。 val() 变成空白

标签 javascript jquery html

我有一个输入框:

<input type="password" name="password" id="password" autocomplete="on" required="" class="ui-state-valid">

当页面最初加载并自动完成命中时,$("#password").val() 返回一个“”。即使自动完成插入了值。

这会导致自定义占位符出现问题。

我需要知道为什么该值为空。我在页面中还有其他输入字段,可以很好地使用自动完成功能。

最佳答案

As of Internet Explorer11, the autocomplete property is no longer supported for input type=password fields.

The AutoComplete feature is highlighted in the Using AutoComplete in HTML Forms overview.

When AutoComplete is enabled, suggestions are provided for the value of a text field. Suggested values are mapped values based on the name attribute or vCard schema specified by the vcard_name attribute.

If AutoComplete is disabled, values are not stored and suggested values are not presented.

Values in input type=password elements can be mapped for AutoComplete; however, the ability to store this information can be disabled in the browser, and the user is prompted for a confirmation before the value is stored.

Information provided by the AutoComplete feature is not exposed to the object model, and is not visible to a Web page until the user selects one of the suggestions as a value for the text field.

引用:- here

关于javascript - 启用自动完成的输入类型密码。 val() 变成空白,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25301348/

相关文章:

javascript - 我如何获得 Todo 的 Id

javascript - Javascript 中的工作流引擎

javascript - 需要同时在MAP上按多边形绘制美国各县

jquery - 使用 jQuery tablesorter.js 避免/禁用排序过程中的某些特定行

javascript - 来自环境变量的Angular 2 base href

javascript - 获取输入数组的第 n 个键值

javascript - 用 Jest 测试 NestJs 服务

javascript - 检查Javascript中的时差

javascript - 如何旋转 Accordion 正文?

javascript - 使用 JQuery 的 nicEditor 和 onchange 事件