Hi !
If you want to validate number that was enter in this textbox
why don't you use this instead of event.
Cause then you would get access to the object who called this function.
So if you HTML will look like this :
<input type="text" name="max_no" onkeypress="return ValidateNum(this);">
You can create this function as follow:
function ValidateNum(obj)
{
if (obj.value == something)
alert("OK");
else
alert("NO");
}
Ah, one more thing, if you trying to refer to max_no by name in your
function
and you use IE you should add id=max_no cause otherwise it won't work.
Oleg.
-----Original Message-----
From: Shankar [mailto:bgs@s...]
Sent: January 11, 2002 12:11 AM
To: JavaScript HowTo
Subject: [javascript_howto] Problem with function Call...!
Hi All,
I have a function, which validates a number. I am calling this function
in "onkeypress" event of two text boxes. But it works fine for only one
text box. I just copied and pasted the same code, then renamed the textbox
name.
Its working fine for the second text box (min_no). I just included an alert
message
in the function and found that, for the first text box, the function call is
not
happening.
Please reply me, what could be the reason. Any help would be
appreciated.
Thanks in Advance.
Regards,
Shankar
<tr>
<td> Maximum No </td>
<td>
<input type="text" name="max_no" onkeypress="return ValidateNum(event);">
</td>
</tr>
<tr>
<td> Minimum No </td>
<td>
<input type="text" name="min_no" onkeypress="return ValidateNum(event);">
</td>
</tr>
Regards,
Shankar
$subst('Email.Unsub').