all groups > dotnet jscript > january 2006 >
You're in the

dotnet jscript

group:

UNDERSTANDING IT IS a NUMBER OR NON-NUMBER


UNDERSTANDING IT IS a NUMBER OR NON-NUMBER Savas Ates
1/26/2006 3:04:38 PM
dotnet jscript:
i have a text field in my html page. I want to diferentiate in this text box
either it is a number or not ? how can i do that ?

Re: UNDERSTANDING IT IS a NUMBER OR NON-NUMBER Yunus Emre ALPÖZEN [MVP]
1/26/2006 9:37:49 PM
Try the following function, parseInt tries to parse given value if
strValue="12a" parseInt returns 12 but the following code snippet returns
false... If strValue="11" parseInt returns 11 and this code snippet returns
true... If strValue=="a12" parseInt returns "NaN" (Not a Number) and this
code snippet returns false as expected...

function IsInteger(strValue)
{
return parseInt(strValue,0)==strValue
}

--
HTH

Thanks,
Yunus Emre ALPÖZEN
BSc, MCSD.NET
Microsoft .NET & Security MVP

[quoted text, click to view]

Re: UNDERSTANDING IT IS a NUMBER OR NON-NUMBER Savas Ates
1/27/2006 12:00:00 AM
saol.. burada ingilisce konusmakta iki turk olarak tuhafima gitti biras :)


"Savas Ates" <in da club>, haber iletisinde þunlarý
yazdý:OPjhTknIGHA.528@TK2MSFTNGP12.phx.gbl...
[quoted text, click to view]

Re: UNDERSTANDING IT IS a NUMBER OR NON-NUMBER Josh Twist
2/2/2006 4:32:01 AM
You could also use the built-in isNaN(value) function...

isNaN("1.8353") = false;
isNaN("3.12E-10") = false;
isNaN("this is not a number") = true;

Josh
http://www.thejoyofcode.com/
AddThis Social Bookmark Button