This discussion is archived
1 Reply Latest reply: Nov 16, 2012 4:04 AM by gimbal2 RSS

Object expected error in java script...

Chanchal Wankhade Journeyer
Currently Being Moderated
Dear All,

we have Java Struts 1.1...



I am getting "Object Expected" error while processing jsp page.
I want to modify the text field so that only number and one dot(.) should be entered.
I have one function and i am calling it as "onkeypress" event.

Below is the function....
function isNumberKey(evt) 
{ 
alert("here"); 
var charCode; 
clearerror(); 
charCode = (evt.which) ? evt.which : event.keyCode 
alert("here"); 
if (charCode != 46 && charCode > 31 && (charCode < 48 || charCode > 57)) 
{ 
return false; 
} 

return true; 
} 

and below are html tags... 
<td>Total No Of Customers  *</td> 
<td><html:text property="noOfCustomersUnit" onkeypress="return isNumberKey(event)" style="width:160px"/></td> 
Please suggest how to solve the issue....
  • 1. Re: Object expected error in java script...
    gimbal2 Guru
    Currently Being Moderated
    Why? This is not a javascript forum.

    In any case, run it in firefox which has decent Javascript error handling functionality, then do some Google searches on Javascript event handling to try and figure out what you're doing wrong. It might be something browser specific and I suggest you look into using something like JQuery for standardized and proven ways to do things like event handling logic in stead of rolling your own Javascript stuff.

Legend

  • Correct Answers - 10 points
  • Helpful Answers - 5 points