Peter,
 
Must have been the "javascript:".  Once I removed it, it worked fine.
 
What's strange is that I have done it that way about a dozen times w/o an error.
 
Anyhow, thanks for the help.
 
Mark

Peter Brunone <[EMAIL PROTECTED]> wrote:
Hi Mark,

      These may or may not be related to your problem, but I see a few
errors in your code below.

1)  There is no semicolon after the first line of the function.

2)  The indexOf() method returns an integer, not a string.

3)  You don't need the "javascript:" pseudoprotocol in an event handler.
You should just have the function call.

      That said, what line does it say throws the error?

Cheers,

Peter

-----Original Message-----
From: Mark E [mailto:[EMAIL PROTECTED] 

All,

I have a javascript function that prevents users from entering
non-numeric values into a textbox.

I add the function to the onkeypress for the textbox in the code-behind
page.

When I press any key, I am getting an 'object expected' error.

Here is the line of code in the code-behind page that adds the function
call the textbox:

txtUnitPrice.Attributes.Add("onkeypress", "javascript:return
NumericOnly();")

And here is the javascript function:

function NumericOnly(){
var valid = "0123456789."
var testChar;
testChar = String.fromCharCode(event.keyCode);
if (valid.indexOf(testChar) == "-1") {
  return false; } 
else {
  return true;
}
}

Doea anyone see what I am doing wrong?  

Thanks,
Mark




[Non-text portions of this message have been removed]





Yahoo! Groups Links








Yahoo! Groups SponsorADVERTISEMENT


---------------------------------
Yahoo! Groups Links

   To visit your group on the web, go to:
http://groups.yahoo.com/group/AspNetAnyQuestionIsOk/
  
   To unsubscribe from this group, send an email to:
[EMAIL PROTECTED]
  
   Your use of Yahoo! Groups is subject to the Yahoo! Terms of Service. 



[Non-text portions of this message have been removed]



------------------------ Yahoo! Groups Sponsor --------------------~--> 
Make a clean sweep of pop-up ads. Yahoo! Companion Toolbar.
Now with Pop-Up Blocker. Get it for free!
http://us.click.yahoo.com/L5YrjA/eSIIAA/yQLSAA/saFolB/TM
--------------------------------------------------------------------~-> 

 
Yahoo! Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/AspNetAnyQuestionIsOk/

<*> To unsubscribe from this group, send an email to:
    [EMAIL PROTECTED]

<*> Your use of Yahoo! Groups is subject to:
    http://docs.yahoo.com/info/terms/
 

Reply via email to