检测文档准备好的自动填充值 [英] Detecting autofilled values on document ready

查看:27
本文介绍了检测文档准备好的自动填充值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个登录页面,我试图在该页面上切换按钮的显示以允许用户修改他们的角色(从用户的可用角色列表中选择).

I have a login page on which I am trying to toggle the display of a button to allow the user to modify their roles (pick from a list of their user's available roles).

我最初隐藏按钮并在 $("#txtUsername").blur() 上显示它.

I am hiding the button initially and showing it on $("#txtUsername").blur().

我的问题:有没有办法获取 Chrome 自动填充值?

My question: is there a way to pick up a Chrome Autofilled value?

如果我尝试在文档准备好时触发它,则值为空,并且按钮不显示.

If I try to trigger it on document ready, the value is blank, and the button doesn't show.

$(function () {
    $("#btnRoles").hide();
    $("#txtUsername").blur(function () {
        if ($(this).val()) $("#btnRoles").show();
        else $("#btnRoles").hide();
    }).trigger("blur");
});

但是文本框然后通过自动填充填充.有什么想法吗?

But the textbox is then filled in via Autofill. Any ideas?

推荐答案

在页面加载后,我找不到任何可以专门读取值的内容.我最终通过使用 $("#txtUsername").trigger("focus") 强制将焦点放在文本框上,因此当用户执行任何操作时,它都会调用 .blur() 并填写角色.

I couldn't find anything to read the values specifically after the page had loaded. I ended up forcing the focus on the textbox by using $("#txtUsername").trigger("focus"), so when the user did anything it would call .blur() and fill in the roles.

这篇关于检测文档准备好的自动填充值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆