Ureader.com  
Microsoft software help and Community
   home   |   control panel login   |   archive   |  
 
inet
active_desktop
active_scrptng
asp.components
asp.db
asp.general
comctl32
comp.packaging
components.dev
dbweb
dhtml_editing
docobjects
html_authoring
html_objmodel
iis
iis.ftp
iis.security
iis.smtp_nntp
indexserver
misc
mshtml_hosting
scripting.jscript
scripting.vbscript
sdk_setup
shell_objmodel
urlmonikers
webbrowser_ctl
wininet
  
 
date: Tue, 11 Apr 2006 19:10:01 -0700,    group: microsoft.public.inetsdk.programming.scripting.jscript        back       


how to check the input value is decimal   
how to check the input value is decimal in javascript
e.g
10000 ok
10000.11 ok
10000.111 not ok
f10000 not ok
aaaaaaaaaa not ok
1f000000 not ok
date: Tue, 11 Apr 2006 19:10:01 -0700   author:   joe

Re: how to check the input value is decimal   
"joe"  wrote in message
news:D5009544-A87D-4B90-8241-304A1255296A@microsoft.com
> how to check the input value is decimal in javascript
> e.g
> 10000 ok
> 10000.11 ok
> 10000.111 not ok
> f10000 not ok
> aaaaaaaaaa not ok
> 1f000000 not ok

var s = "10000.11";
if (isNaN(Number(s))) {
    // not a valid number
}

I don't quite understand why 10000.11 is OK with you but 10000.111 is 
not. Both look decimal enough to me. Both will pass the test above.
-- 
With best wishes,
    Igor Tandetnik

With sufficient thrust, pigs fly just fine. However, this is not 
necessarily a good idea. It is hard to be sure where they are going to 
land, and it could be dangerous sitting under them as they fly 
overhead. -- RFC 1925
date: Tue, 11 Apr 2006 22:25:55 -0400   author:   Igor Tandetnik

Re: how to check the input value is decimal   
i don't want it have  more than two precision
e.g
xxx.xx ok
xxx.xxx not ok


"Igor Tandetnik" wrote:

> "joe"  wrote in message
> news:D5009544-A87D-4B90-8241-304A1255296A@microsoft.com
> > how to check the input value is decimal in javascript
> > e.g
> > 10000 ok
> > 10000.11 ok
> > 10000.111 not ok
> > f10000 not ok
> > aaaaaaaaaa not ok
> > 1f000000 not ok
> 
> var s = "10000.11";
> if (isNaN(Number(s))) {
>     // not a valid number
> }
> 
> I don't quite understand why 10000.11 is OK with you but 10000.111 is 
> not. Both look decimal enough to me. Both will pass the test above.
> -- 
> With best wishes,
>     Igor Tandetnik
> 
> With sufficient thrust, pigs fly just fine. However, this is not 
> necessarily a good idea. It is hard to be sure where they are going to 
> land, and it could be dangerous sitting under them as they fly 
> overhead. -- RFC 1925 
> 
> 
>
date: Tue, 11 Apr 2006 19:57:01 -0700   author:   joe

Re: how to check the input value is decimal   
"joe"  wrote in message
news:61844B5B-6753-4191-9E19-03A6A75104ED@microsoft.com
> i don't want it have  more than two precision
> e.g
> xxx.xx ok
> xxx.xxx not ok

Test your string against a regular expression. Something like this:

var re = /^\s*\d+(\.\d{0,2})?\s*$/;
var s = "123.45";
if (!re.test(s)) {
    // Not a valid number
}

-- 
With best wishes,
    Igor Tandetnik

With sufficient thrust, pigs fly just fine. However, this is not 
necessarily a good idea. It is hard to be sure where they are going to 
land, and it could be dangerous sitting under them as they fly 
overhead. -- RFC 1925
date: Tue, 11 Apr 2006 23:33:47 -0400   author:   Igor Tandetnik

Re: how to check the input value is decimal   
"precision" is part of the documentation

"toPrecision" or such

check your file.




"joe"  wrote in message
news:61844B5B-6753-4191-9E19-03A6A75104ED@microsoft.com...
> i don't want it have  more than two precision
> e.g
> xxx.xx ok
> xxx.xxx not ok
>
>
> "Igor Tandetnik" wrote:
>
> > "joe"  wrote in message
> > news:D5009544-A87D-4B90-8241-304A1255296A@microsoft.com
> > > how to check the input value is decimal in javascript
> > > e.g
> > > 10000 ok
> > > 10000.11 ok
> > > 10000.111 not ok
> > > f10000 not ok
> > > aaaaaaaaaa not ok
> > > 1f000000 not ok
> >
> > var s = "10000.11";
> > if (isNaN(Number(s))) {
> >     // not a valid number
> > }
> >
> > I don't quite understand why 10000.11 is OK with you but 10000.111 is
> > not. Both look decimal enough to me. Both will pass the test above.
> > -- 
> > With best wishes,
> >     Igor Tandetnik
> >
> > With sufficient thrust, pigs fly just fine. However, this is not
> > necessarily a good idea. It is hard to be sure where they are going to
> > land, and it could be dangerous sitting under them as they fly
> > overhead. -- RFC 1925
> >
> >
> >
date: Sat, 22 Apr 2006 01:30:38 -0400   author:   asdf

Google
 
Web ureader.com


    COPYRIGHT 2007, YARDI TECHNOLOGY LIMITED, ALL RIGHT RESERVE  |   contact us