minil minil - 1 year ago 148
Javascript Question

How to pass parameter to the attachEvent javascript function

I have to pass paramter the validateNum javascript function (eg. num1, num2)

if (num1.attachEvent) {
num1.attachEvent("onkeypress", validateNum);

How to pass. can i get code sample?

Answer Source

You need to make an anonymous currier:

num1.attachEvent("onkeypress", function() { return validateNum(num1, num2); });  
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download