minil minil - 11 months ago 93
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?


You need to make an anonymous currier:

num1.attachEvent("onkeypress", function() { return validateNum(num1, num2); });