最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

html - How to pass input text as parameter to javascript onblur event? - Stack Overflow

programmeradmin3浏览0评论

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.

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?

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.

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?

Share Improve this question asked Aug 14, 2014 at 11:01 aarelovichaarelovich 5,56615 gold badges64 silver badges123 bronze badges 3
  • 1 It should be this.value. That's all. – emerson.marini Commented Aug 14, 2014 at 11:03
  • please use this.value it will pass the value in the textbox on the event – Murtaza Commented Aug 14, 2014 at 11:03
  • Do you have any errors in the console ? It should work as expected, provided you change onblur="checkDateFormat(this.date_t.value)" to onblur="checkDateFormat(this.value)" – Waldo Jeffers Commented Aug 14, 2014 at 11:03
Add a comment  | 

2 Answers 2

Reset to default 16

Try to use,

 onblur="checkDateFormat(this.value)" 

Instead of

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

Try checkDateFormat(this.value) instead.

发布评论

评论列表(0)

  1. 暂无评论