如何将输入文本作为参数传递给 javascript onblur 事件?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/25306451/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-28 04:21:10  来源:igfitidea点击:

How to pass input text as parameter to javascript onblur event?

javascripthtmlinput

提问by aarelovich

This is the code for an input text field. What I want is to call the "checkDateFormat" function with the text input as a parameter when the user leaves the field.

这是输入文本字段的代码。我想要的是在用户离开该字段时以文本输入作为参数调用“checkDateFormat”函数。

Here is the code I've written:

这是我写的代码:

Fecha de prueba: <input type="text" name="date_t" id="date_t" value="22/08/2014" onblur="checkDateFormat(this.date_t.value)"><br>

However I'm sure the function isn't even called.

但是我确信这个函数甚至没有被调用。

What am I doing wrong?

我究竟做错了什么?

回答by Shijin TR

Try to use,

尝试使用,

 onblur="checkDateFormat(this.value)" 

Instead of

代替

 onblur="checkDateFormat(this.date_t.value)"

回答by icke

Try checkDateFormat(this.value)instead.

试试吧checkDateFormat(this.value)