输入更改时如何运行javascript函数 [英] How can I run a javascript function when input changes
本文介绍了输入更改时如何运行javascript函数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
当用户在我的网站上创建一个新帐户时,我想检查该名称是否已经存在.当他们离开用户名输入框并输入密码时,我希望运行此检查.
When a user creates a new account on my website I want to check if the name already exists. I want this check to run when they leave the username input box and go to enter a password.
我尝试过:
<input type="text" onkeyup="check_user(this.value)"/>
推荐答案
您需要使用"onblur"事件.当控件失去焦点时就会触发,这似乎正是您所需要的.
You need to use the "onblur" event. It fires when a control loses its focus, which seems to be exactly what you need.
这篇关于输入更改时如何运行javascript函数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文