A friendly place for programming greenhorns!
Big Moose Saloon
Register / Login
Joined: Apr 24, 2008
May 01, 2009 07:49:29
isNaN function only checks first letter in
.. but what suppose I have string like sa89bh.
is there any function for recognizing numbers in string ?
which are the built in functions in
SCJP 6 (88%), SCWCD 5 (78%), preparing for SCBCD
Joined: Nov 08, 2001
May 01, 2009 08:30:04
alert("a123a".match(/\d+/)) //123 alert("a123a321a".match(/\d+/)) //123 alert("a123a".match(/\d+/gi)) //123 alert("a123a321a".match(/\d+/gi)) //123,321
Author and ninkuma
Joined: Jan 10, 2002
May 01, 2009 08:31:24
If the first letter is not a numeral, that's all isNan needs to know to determine if it's a number of not.
If you are trying to find embedded numbers, why would you use isNan? I'd consider exploring regular expressions.
Edit: As Eric suggested while I was posting.
Asking smart questions
Books by Bear
subject: isNaN function
Input field validations
how to take either String or numbers..in textbox
Validating alpha and numeric chars in a form
All times are in JavaRanch time: GMT-6 in summer, GMT-7 in winter
| Powered by
Copyright © 1998-2015