'How to attach an event in IE?

I try to attach an event on a input element, then I put this code on onload of body element:

bornDate.attachEvent("onblur", validade(true));

But in onload, the function validade executes! I want the function executes only on onblur of bornDate element.



Solution 1:[1]

To keep validade from executing, you have to embed the function call inside a function. The function reference gets passed to attachEvent.

bornDate.attachEvent("onblur", function () {
    validade(true);
});

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1