This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes HTML, CSS and JavaScript and the fly likes to check double values Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Bookmark "to check double values" Watch "to check double values" New topic
Author

to check double values

Debashree Halder
Ranch Hand

Joined: Jul 27, 2005
Posts: 81
I want to check whether the entered value in a textbox is an integer or double value. How can I check this?

[Bear edit: fixed typo in subject: check is not spelled chk]
[ September 28, 2005: Message edited by: Bear Bibeault ]

Debashree Halder<br />SCJP 1.5<br />Washington DC
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60752
    
  65

The value entered into a text box is always a string. Are you asking how to convert this string into int or double values?


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
sandeep TA
Greenhorn

Joined: Feb 14, 2005
Posts: 11
Yes it will be stored as string


for double conversion

Double.getDouble(str)
Debashree Halder
Ranch Hand

Joined: Jul 27, 2005
Posts: 81
Actually I want to use keyPress function.

If user presses any thing other than 0-9 and decimal point (.) it will show an alert box telling "You can only enter numbers".

How can I achieve this?
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60752
    
  65

That is a client-side activity that you must use Javascript for.

Moved to the HTML/Javascript forum.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: to check double values
 
Similar Threads
Very Basic Question
Argh! Weird Occurence on JRE 1.3.1 - What am I doing wrong?
Blanking out a button if they do not have enough funds in their bank.
Return Statement with in if condition
Creating new user with full admin rights.