Onblur event doesnt work for input

Hi I was trying to attach onblur event to one of the input fields on my form. On blur of input field I wanted to load dropdown.

var inpId = myformform.getInput("inpId");
inpId.onblur = doOnBlur;

function doOnBlur(){
alert("on blur event..");

I also tried

var inpId = myformform.getInput("inpId");

if (window.addEventListener) {
} else {

In both cases at line “inpId.onblur = doOnBlur” I see javascript error. Null or not an object.

I also tried onbeforechange event. That is never fired!

Can someone please help me attach onblur event to input field.


any ideas?


declare doOnBlur first, then inp.onblur=doOnBlur
form also used onblur, better use 2nd case (addEventListener)

Thankyou. The second solution worked.