使用 jQuery 检测表单输入的自动完成 [英] Detecting autocomplete on form input with jQuery

查看:32
本文介绍了使用 jQuery 检测表单输入的自动完成的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个表单,可以检测每个 keyup() 和 focus() 上的所有文本字段是否都有效;如果它们都有效,它将启用提交按钮供用户按下.但是,如果用户使用浏览器自动完成功能填写其中一个文本输入,则会阻止启用提交按钮.

I have a form that detects if all the text-fields are valid on each keyup() and focus(); if they're all valid, it will enable the submit button for the user to press. However, if the user fills in one of the text inputs with a browsers autocomplete feature, it prevents the submit button from being enabled.

有没有一种方法可以使用 jQuery 检测任何输入是否已更改,而不管它是如何更改的?

Is there a way to detect if any of the input has changed regardless of how it's been changed, using jQuery?

推荐答案

jQuery 更改事件只会在模糊时触发.keyup 事件将在您键入时触发.单击自动完成选项时都不会触发.我也在寻找一种方法来检测这个,但我目前正在使用

The jQuery change event will only fire on blur. The keyup event will fire as you type. Neither fire on clicking an auto-completion option. I am also searching for a way to detect this, but I'm currently going with

$(selector).bind("change keyup",function(){
    //Do something, probably with $(this).val()
});

但这并不能完全解决问题...

But it doesn't quite solve the problem...

这篇关于使用 jQuery 检测表单输入的自动完成的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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