-1

I am using struts 1. I have a textbox like this

<html:text name="test" property="testProperty" size="10" onBlur="someJavascriptFunc()"  /> 

Its throwing an error while compiling

Attribute onBlur invalid for tag text according to TLD

How can I invole this javascript function?

RockAndRoll
  • 2,247
  • 2
  • 16
  • 35

2 Answers2

1

Try this in your JavaScript Code

var x = document.getElementsByName("test")[0];
x.Attributes.Add("onBlur", "javascript:return someJavascriptFunc()");
Sid M
  • 4,354
  • 4
  • 30
  • 50
  • it needs to be called on page load? – RockAndRoll Nov 24 '15 at 11:12
  • 1
    @PrinceManiGupta: you can call it in `window.onload = function(e){ var x = document.getElementsByName("test")[0]; x.Attributes.Add("onBlur", "javascript:return someJavascriptFunc()"); }` inside your script tags and also define `someJavascriptFunc()` in the script tags – Sid M Nov 24 '15 at 11:19
  • Thanks for your help.It worked when I changed from `onBlur` to `onblur`. – RockAndRoll Nov 24 '15 at 11:35
0

I checked the documentation and found that its actually onblur.

It worked when I changed function name onBlur to onblur.

RockAndRoll
  • 2,247
  • 2
  • 16
  • 35