f



JavaScript Regex

Dear JavaScripters:

     I have not found quite the detail that I need for regexes.  If
you have a URL to a good site, please post it.  In particular, how do
I group subexpressions?

     I wish to parse a string to see if it is a valid fixed-decimal
value.

     I start with
          /^

     How do I check a set of characters optionally?  I want to check
for a sign character.  The string might start with "+" or "-", but if
it starts with neither, that is fine.  Do I leave an empty choice in a
parens set?  Is it then
          ([+-]|)
or
          [+-]?
?

     Then come optional digits:
          \d*

     Then another complex maybe for the decimal point and digits
following:
          (\.\d*|)
or
          (\.\d*)?
?

     And the end
          $/

     The regex should accept:
          123
          +123
          -123
          123.
          +123.
          -123.
          123.45
          +123.45
          -123.45

     It will also accept
          .
          +.
          -.
That is acceptable.  I will check for digits with another regex.

Sincerely,

Gene Wirchenko
0
genew (1214)
1/12/2012 4:51:26 AM
comp.lang.javascript 38370 articles. 0 followers. javascript4 (1315) is leader. Post Follow

19 Replies
1037 Views

Similar Articles

[PageSpeed] 14

On Wed, 11 Jan 2012 20:51:26 -0800, Gene Wirchenko wrote:

>     I have not found quite the detail that I need for regexes.  If
>you have a URL to a good site, please post it.  

http://www.regular-expressions.info/

But note:
http://www.regular-expressions.info/javascript.html

Also useful:
https://developer.mozilla.org/en/JavaScript/Guide/Regular_Expressions
https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/RegExp

>In particular, how do
>I group subexpressions?
>
>     I wish to parse a string to see if it is a valid fixed-decimal
>value.
>
>     I start with
>          /^
>
>     How do I check a set of characters optionally?  I want to check
>for a sign character.  The string might start with "+" or "-", but if
>it starts with neither, that is fine.  Do I leave an empty choice in a
>parens set?  Is it then
>          ([+-]|)
>or
>          [+-]?
>?

The latter.

>     Then come optional digits:
>          \d*
>
>     Then another complex maybe for the decimal point and digits
>following:
>          (\.\d*|)
>or
>          (\.\d*)?
>?

Again, the latter.

>[...]
>     The regex should accept:
>          123
>          +123
>          -123
>          123.
>          +123.
>          -123.
>          123.45
>          +123.45
>          -123.45
>
>     It will also accept
>          .
>          +.
>          -.
>That is acceptable.  I will check for digits with another regex.

See here for a good tutorial on this problem:
http://www.regular-expressions.info/floatingpoint.html
-- 
Ross McKay, Toronto, NSW Australia
"Some people, when confronted with a problem, think "I know,
 I'll use regular expressions." Now they have two problems.
 - Jamie Zawinski
0
1/12/2012 6:07:45 AM
On Wed, 11 Jan 2012 20:51:26 -0800, Gene Wirchenko wrote:

>      I wish to parse a string to see if it is a valid fixed-decimal
> value.

/^[+-]?\d{1,}(\.\d*)?$/

http://www.sined.co.uk/tmp/regex.htm

Rgds

Denis McMahon
0
1/12/2012 3:05:27 PM
Denis McMahon wrote:

> On Wed, 11 Jan 2012 20:51:26 -0800, Gene Wirchenko wrote:
>>      I wish to parse a string to see if it is a valid fixed-decimal
>> value.
> 
> /^[+-]?\d{1,}(\.\d*)?$/
> 
> http://www.sined.co.uk/tmp/regex.htm

Wrong, see the ECMAScript Language Specification and, e. g., the JSON 
website.  And what is *fixed* about this?

  !isNaN(+s)

where `s' is a String value, suffices for strings representing floating-
point values.  If "fixed" is supposed to mean "a fixed number of decimals", 
a more elaborate expression needs to be used, but not this one (what about 
leading "." and scientific notation?).  We have been over this.


PointedEars
-- 
var bugRiddenCrashPronePieceOfJunk = (
    navigator.userAgent.indexOf('MSIE 5') != -1
    && navigator.userAgent.indexOf('Mac') != -1
)  // Plone, register_function.js:16
0
PointedEars (2489)
1/12/2012 3:42:38 PM
Denis McMahon wrote on 12 jan 2012 in comp.lang.javascript:

> On Wed, 11 Jan 2012 20:51:26 -0800, Gene Wirchenko wrote:
> 
>>      I wish to parse a string to see if it is a valid fixed-decimal
>> value.
> 
> /^[+-]?\d{1,}(\.\d*)?$/

var result = !isNaN(t) && !/[e\s]/i.test(t)

[allows  .123 ]


-- 
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)
0
1/12/2012 3:56:54 PM
Thomas 'PointedEars' Lahn wrote on 12 jan 2012 in comp.lang.javascript:

> Denis McMahon wrote:
> 
>> On Wed, 11 Jan 2012 20:51:26 -0800, Gene Wirchenko wrote:
>>>      I wish to parse a string to see if it is a valid fixed-decimal
>>> value.
>> 
>> /^[+-]?\d{1,}(\.\d*)?$/
>> 
>> http://www.sined.co.uk/tmp/regex.htm
> 
> Wrong, see the ECMAScript Language Specification and, e. g., the JSON 
> website.  And what is *fixed* about this?
> 
>   !isNaN(+s)

Will also accept "2.2e7" which is not a fixed-decimal but floating.

There is no need for the +, as isNaN() will accept a string,
and do the conversion internally.

> where `s' is a String value, suffices for strings representing
> floating- point values.  If "fixed" is supposed to mean "a fixed
> number of decimals", a more elaborate expression needs to be used, but
> not this one (what about leading "." and scientific notation?).  We
> have been over this. 



-- 
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)
0
1/12/2012 4:09:12 PM
On Thu, 12 Jan 2012 17:07:45 +1100, Ross McKay
<au.org.zeta.at.rosko@invalid.invalid> wrote:

>On Wed, 11 Jan 2012 20:51:26 -0800, Gene Wirchenko wrote:
>
>>     I have not found quite the detail that I need for regexes.  If
>>you have a URL to a good site, please post it.  
>
>http://www.regular-expressions.info/
>
>But note:
>http://www.regular-expressions.info/javascript.html
>
>Also useful:
>https://developer.mozilla.org/en/JavaScript/Guide/Regular_Expressions
>https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/RegExp

[snip]

>See here for a good tutorial on this problem:
>http://www.regular-expressions.info/floatingpoint.html

     Thank you for the links and for the confirmation of my regex.

     Actually, I am not concerned about floating-point.  My app will
only use integers and fixed-point numbers.

Sincerely,

Gene Wirchenko
0
genew (1214)
1/12/2012 8:13:47 PM
Gene Wirchenko wrote on 12 jan 2012 in comp.lang.javascript:

> Actually, I am not concerned about floating-point.  My app will
> only use integers and fixed-point numbers.

If so, and if you don't need to disallow whitespace,

var boolResult = !isNaN(str);

will do.

-- 
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)
0
1/12/2012 8:48:13 PM
In comp.lang.javascript message <Xns9FD8DDCD38A6Beejj99@194.109.133.133>
, Thu, 12 Jan 2012 20:48:13, Evertjan. <exjxw.hannivoort@interxnl.net>
posted:

>Gene Wirchenko wrote on 12 jan 2012 in comp.lang.javascript:
>
>> Actually, I am not concerned about floating-point.  My app will
>> only use integers and fixed-point numbers.
>
>If so, and if you don't need to disallow whitespace,
>
>var boolResult = !isNaN(str);

Accepts   str = "0x0"   which is probably not wanted.

-- 
 (c) John Stockton, nr London UK.  ?@merlyn.demon.co.uk  DOS 3.3 6.20 ; WinXP.
   Web  <http://www.merlyn.demon.co.uk/> - FAQqish topics, acronyms & links.
   PAS EXE TXT ZIP via  <http://www.merlyn.demon.co.uk/programs/00index.htm>
   My DOS  <http://www.merlyn.demon.co.uk/batfiles.htm> - also batprogs.htm.
0
reply1202 (5)
1/14/2012 8:41:07 PM
In comp.lang.javascript message <Xns9FD8AC68C9038eejj99@194.109.133.133>
, Thu, 12 Jan 2012 15:56:54, Evertjan. <exjxw.hannivoort@interxnl.net>
posted:

>Denis McMahon wrote on 12 jan 2012 in comp.lang.javascript:
>
>> On Wed, 11 Jan 2012 20:51:26 -0800, Gene Wirchenko wrote:
>>
>>>      I wish to parse a string to see if it is a valid fixed-decimal
>>> value.
>>
>> /^[+-]?\d{1,}(\.\d*)?$/
>
>var result = !isNaN(t) && !/[e\s]/i.test(t)
>
>[allows  .123 ]

Such should NOT be allowed, if there is any option (IUPAP/SUNAMCO) - an
inadequately-guarded dot can too easily fail to be noticed.

-- 
 (c) John Stockton, nr London UK.  ?@merlyn.demon.co.uk  Turnpike v6.05  MIME.
   <http://www.merlyn.demon.co.uk/>  TP/BP/Delphi/&c., FAQqy topics & links;
   <http://www.merlyn.demon.co.uk/clpb-faq.txt>    RAH Prins : c.l.p.b mFAQ;
   <ftp://garbo.uwasa.fi/pc/link/tsfaqp.zip>  Timo Salmi's Turbo Pascal FAQ.
0
reply1202 (5)
1/14/2012 8:44:50 PM
In comp.lang.javascript message <8kosg7tha6n6epo47krtaulm9a269kvclo@4ax.
com>, Wed, 11 Jan 2012 20:51:26, Gene Wirchenko <genew@ocis.net> posted:

>
>     I have not found quite the detail that I need for regexes.  If
>you have a URL to a good site, please post it.

<http://www.merlyn.demon.co.uk/js-valid.htm> lists some that I have
found.


>     I wish to parse a string to see if it is a valid fixed-decimal
>value.

Cannot actually be done.  "2012" may in truth be 2^8+1, to base 5.

And 014747 is really a bit pattern representation of a computer
instruction, highly amusing to those who can read PDP-11 code; it does
not mean decimal 6631.

For human input, you should generally allow leading and trailing
whitespace.  Then an optional sign.  Then at least one digit.  Then,
optionally, (a decimal point followed by at least one digit).  In any
particular application, you can probably also limit the number of
digits; for example, in currency, except for Government work, any more
than say nine digits before the decimal point probably means that the
cat has walked along the keyboard, or the euro has crashed, etc.


<http://www.merlyn.demon.co.uk/js-valid.htm#VNP> has what you need, if
you remove the exponent part.

-- 
 (c) John Stockton, nr London, UK.    ?@merlyn.demon.co.uk     Turnpike v6.05.
 Website  <http://www.merlyn.demon.co.uk/> - w. FAQish topics, links, acronyms
 PAS EXE etc. : <http://www.merlyn.demon.co.uk/programs/> - see in 00index.htm
 Dates - miscdate.htm estrdate.htm js-dates.htm pas-time.htm critdate.htm etc.
0
reply1202 (5)
1/14/2012 9:23:20 PM
Dr J R Stockton wrote on 14 jan 2012 in comp.lang.javascript:

> n comp.lang.javascript message <Xns9FD8DDCD38A6Beejj99@194.109.133.133>
> , Thu, 12 Jan 2012 20:48:13, Evertjan. <exjxw.hannivoort@interxnl.net>
> posted:
> 
>>Gene Wirchenko wrote on 12 jan 2012 in comp.lang.javascript:
>>
>>> Actually, I am not concerned about floating-point.  My app will
>>> only use integers and fixed-point numbers.
>>
>>If so, and if you don't need to disallow whitespace,
>>
>>var boolResult = !isNaN(str);
> 
> Accepts   str = "0x0"   which is probably not wanted.

Probably not, the OP stipulated that floating point etc. need not be 
concidered, that's why I simplified my original.

Try for completeness:

var boolResult = !isNaN(t) && /[^\d\.]/i.test(t)


-- 
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)
0
1/15/2012 8:08:20 PM
On Sat, 14 Jan 2012 21:23:20 +0000, Dr J R Stockton
<reply1202@merlyn.demon.co.uk> wrote:

>In comp.lang.javascript message <8kosg7tha6n6epo47krtaulm9a269kvclo@4ax.
>com>, Wed, 11 Jan 2012 20:51:26, Gene Wirchenko <genew@ocis.net> posted:
>
>>
>>     I have not found quite the detail that I need for regexes.  If
>>you have a URL to a good site, please post it.
>
><http://www.merlyn.demon.co.uk/js-valid.htm> lists some that I have
>found.
>
>
>>     I wish to parse a string to see if it is a valid fixed-decimal
>>value.
>
>Cannot actually be done.  "2012" may in truth be 2^8+1, to base 5.

     How fatuous and condescending!  I am checking whether a string is
valid fixed-decimal value.  Whether it can also be interpreted as
something else is irrelevant.

     The rest of your post is similar.  I *have* considered what I
require.  What I asked about is but a small part of it.  (I do believe
in doing my own work as much as I can.)

[snip]

Sincerely,

Gene Wirchenko
0
genew (1214)
1/16/2012 5:10:03 AM
In comp.lang.javascript message <Xns9FDBD7097E631eejj99@194.109.133.133>
, Sun, 15 Jan 2012 20:08:20, Evertjan. <exjxw.hannivoort@interxnl.net>
posted:

>Dr J R Stockton wrote on 14 jan 2012 in comp.lang.javascript:
>
>> n comp.lang.javascript message <Xns9FD8DDCD38A6Beejj99@194.109.133.133>
>> , Thu, 12 Jan 2012 20:48:13, Evertjan. <exjxw.hannivoort@interxnl.net>
>> posted:
>>
>>>Gene Wirchenko wrote on 12 jan 2012 in comp.lang.javascript:
>>>
>>>> Actually, I am not concerned about floating-point.  My app will
>>>> only use integers and fixed-point numbers.
>>>
>>>If so, and if you don't need to disallow whitespace,
>>>
>>>var boolResult = !isNaN(str);
>>
>> Accepts   str = "0x0"   which is probably not wanted.
>
>Probably not, the OP stipulated that floating point etc. need not be
>concidered, that's why I simplified my original.
>
>Try for completeness:
>
>var boolResult = !isNaN(t) && /[^\d\.]/i.test(t)

Works better with another ! !!

That will accept the deprecated forms '1.' and '.1'.

That will accept numbers so long that they read as Infinity.

                        I wonder whether Gene knows how to tell
                        whether a Number is positive or negative?

-- 
 (c) John Stockton, nr London UK  ?@merlyn.demon.co.uk  IE8 FF8 Op11 Sf5 Cr15
   news:comp.lang.javascript FAQ <http://www.jibbering.com/faq/index.html>.
   <http://www.merlyn.demon.co.uk/js-index.htm> jscr maths, dates, sources.
   <http://www.merlyn.demon.co.uk/> TP/BP/Delphi/jscr/&c, FAQ items, links.
0
reply1203 (8)
1/16/2012 9:55:11 PM
In comp.lang.javascript message <c4c7h7t2qghi49i0esm44sl00ki2cq27q9@4ax.
com>, Sun, 15 Jan 2012 21:10:03, Gene Wirchenko <genew@ocis.net> posted:

>On Sat, 14 Jan 2012 21:23:20 +0000, Dr J R Stockton
><reply1202@merlyn.demon.co.uk> wrote:
>
>>In comp.lang.javascript message <8kosg7tha6n6epo47krtaulm9a269kvclo@4ax.
>>com>, Wed, 11 Jan 2012 20:51:26, Gene Wirchenko <genew@ocis.net> posted:
>>
>>>
>>>     I have not found quite the detail that I need for regexes.  If
>>>you have a URL to a good site, please post it.
>>
>><http://www.merlyn.demon.co.uk/js-valid.htm> lists some that I have
>>found.
>>
>>
>>>     I wish to parse a string to see if it is a valid fixed-decimal
>>>value.
>>
>>Cannot actually be done.  "2012" may in truth be 2^8+1, to base 5.
>
>     How fatuous and condescending!  I am checking whether a string is
>valid fixed-decimal value.

No, you are checking whether it can be interpreted as a valid integer or
fixed-point decimal value.  One cannot tell what a string IS by mere
inspection of the string.

>  Whether it can also be interpreted as
>something else is irrelevant.
>
>     The rest of your post is similar.  I *have* considered what I
>require.  What I asked about is but a small part of it.  (I do believe
>in doing my own work as much as I can.)

Doing your own work where reasonable is good.  But regurgitating all the
old and well-known follies here is not good.  We on the whole, or I at
least, would prefer you to take advantage of what is already well-known
and sufficiently published in the field, and then to present new and
therefore interesting problems, so encouraging the advancement of
learning in general.

Remember what Newton said about the shoulders of giants.  And note that
he probably did not invent that saying, but more likely got it
indirectly from Bernard of Chartres.

-- 
 (c) John Stockton, nr London, UK. ?@merlyn.demon.co.uk  Turnpike v6.05  MIME.
  Web  <http://www.merlyn.demon.co.uk/> - FAQqish topics, acronyms and links;
  Astro stuff via astron-1.htm, gravity0.htm ; quotings.htm, pascal.htm, etc.
 No Encoding. Quotes before replies. Snip well. Write clearly. Don't Mail News.
0
reply1203 (8)
1/17/2012 8:01:36 PM
Dr J R Stockton wrote:
> Gene Wirchenko posted:
>> Dr J R Stockton wrote:
>>> Gene Wirchenko posted:
>>>> I wish to parse a string to see if it is a valid fixed-decimal
>>>> value.
>>>
>>> Cannot actually be done. =A0"2012" may in truth be 2^8+1, to base 5.
>>
>> How fatuous and condescending! =A0I am checking whether a string is
>> valid fixed-decimal value.
>
> No, you are checking whether it can be interpreted as a valid integer or
> fixed-point decimal value. =A0One cannot tell what a string IS by mere
> inspection of the string.

Did you really misunderstand?  Or are you being pedantic for no good
reason?

I think it was clear to all other participants approximately what Gene
was asking about, and several helpful responses have already been
given.  Maybe there would have been slightly less ambiguity had he
said, "I wish to programatically determine if a given string matches a
standard format used to represent fixed-point values," or some such,
but I for one had no problem translating "I wish to parse a string to
see if it is a valid fixed-decimal value" to mean much the same.

Now, on the other hand, Gene, the first result in

    http://www.google.com/search?q=3Djavascript+regex+floating+point

is to a Stack Overflow page which has this answer:

    /^[-+]?[0-9]*\.?[0-9]+$/

That might or might not meet your requirements (it allows leading
zeroes and bare decimals), but it could at least be a good starting
point.  And it wasn't hard to find.

  -- Scott
0
scott.sauyet (381)
1/18/2012 1:42:13 PM
In comp.lang.javascript message <Xns9FD8AC68C9038eejj99@194.109.133.133>
, Thu, 12 Jan 2012 15:56:54, Evertjan. <exjxw.hannivoort@interxnl.net>
posted:

>Denis McMahon wrote on 12 jan 2012 in comp.lang.javascript:
>
>> On Wed, 11 Jan 2012 20:51:26 -0800, Gene Wirchenko wrote:
>>
>>>      I wish to parse a string to see if it is a valid fixed-decimal
>>> value.
>>
>> /^[+-]?\d{1,}(\.\d*)?$/
>
>var result = !isNaN(t) && !/[e\s]/i.test(t)
>
>[allows  .123 ]

It also allows "Infinity" with optional sign.

Set t = "NaN", and one can see that "NaN" is wrong; it should be spelt
"Nan", because ECMAscript NaN is undoubtedly a Number but not a number.

-- 
 (c) John Stockton, nr London, UK.    ?@merlyn.demon.co.uk     Turnpike v6.05.
 Website  <http://www.merlyn.demon.co.uk/> - w. FAQish topics, links, acronyms
 PAS EXE etc. : <http://www.merlyn.demon.co.uk/programs/> - see in 00index.htm
 Dates - miscdate.htm estrdate.htm js-dates.htm pas-time.htm critdate.htm etc.
0
reply1203 (8)
1/19/2012 7:59:21 PM
In comp.lang.javascript message <fcf854ac-2bf2-45c9-b458-28f5b07b2c12@i6
g2000vbk.googlegroups.com>, Wed, 18 Jan 2012 05:42:13, Scott Sauyet
<scott.sauyet@gmail.com> posted:

>Dr J R Stockton wrote:
>> Gene Wirchenko posted:
>>> Dr J R Stockton wrote:
>>>> Gene Wirchenko posted:
>>>>> I wish to parse a string to see if it is a valid fixed-decimal
>>>>> value.
>>>>
>>>> Cannot actually be done. �"2012" may in truth be 2^8+1, to base 5.
>>>
>>> How fatuous and condescending! �I am checking whether a string is
>>> valid fixed-decimal value.
>>
>> No, you are checking whether it can be interpreted as a valid integer or
>> fixed-point decimal value. �One cannot tell what a string IS by mere
>> inspection of the string.
>
>Did you really misunderstand?  Or are you being pedantic for no good
>reason?

I know more or less what he meant, but it was expressed in a woolly-
minded manner.  Those are not exact descriptions of what he wants to
test for.

Before designing such a test, it is necessary to know what characters,
if any, can be present before or after the number; whether a sign is
permissible or compulsory or neither, whether a fixed-point number is
required to have a point in it, whether there must be a digit on each
side of the point or it is allowable to have a digit on only one side,
whether starting with <zero><digit> is allowed, whether there should be
any bound on the magnitude, whether there may be thousands separators
(or ones for lakhs & crores, to support the Indian market), etc.

AFAIK, the Canadian Government of Canada (or of Quebec) may impose a
requirement to accept also comma as the decimal separator.

Those who express their needs fully, clearly, and unambiguously may well
realise the solution while doing so, and otherwise are likely to get
useful, accurate answers.


>Now, on the other hand, Gene, the first result in
>
>    http://www.google.com/search?q=javascript+regex+floating+point
>
>is to a Stack Overflow page which has this answer:
>
>    /^[-+]?[0-9]*\.?[0-9]+$/
>
>That might or might not meet your requirements (it allows leading
>zeroes and bare decimals), but it could at least be a good starting
>point.  And it wasn't hard to find.

The answers on my page would have been easy to find, at least after I
gave the URL.  And I know about \d.

-- 
 (c) John Stockton, nr London, UK. ?@merlyn.demon.co.uk  Turnpike v6.05  MIME.
  Web  <http://www.merlyn.demon.co.uk/> - FAQqish topics, acronyms and links;
  Astro stuff via astron-1.htm, gravity0.htm ; quotings.htm, pascal.htm, etc.
 No Encoding. Quotes before replies. Snip well. Write clearly. Don't Mail News.
0
reply1203 (8)
1/19/2012 8:11:42 PM
Dr J R Stockton wrote on 19 jan 2012 in comp.lang.javascript:

>>var result = !isNaN(t) && !/[e\s]/i.test(t)
>>
>>[allows  .123 ]
> 
> It also allows "Infinity" with optional sign.

This better?

Remember we are talking aboutr strings:
t = '-Infinity'
not
t = -Infinity

<script type='text/javascript'>

var t = '-Infinity';
//var t = 'NaN';
//var t = '.259';

var result = !isNaN(t) && !/[a-z\s]/i.test(t);

alert(t+' is a fixed point number?\n'+result);

</script>
 
> Set t = "NaN", and one can see that "NaN" is wrong; it should be spelt
> "Nan", because ECMAscript NaN is undoubtedly a Number but not a number.

A fixed point Number?

-- 
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)
0
1/20/2012 9:19:57 AM
In comp.lang.javascript message <Xns9FE0691ABB4B5eejj99@194.109.133.133>
, Fri, 20 Jan 2012 09:19:57, Evertjan. <exjxw.hannivoort@interxnl.net>
posted:
>Dr J R Stockton wrote on 19 jan 2012 in comp.lang.javascript:

>> Set t = "NaN", and one can see that "NaN" is wrong; it should be spelt
>> "Nan", because ECMAscript NaN is undoubtedly a Number but not a number.
>
>A fixed point Number?

That had no especial reference to GW's number-strings.  Variables of
type Number are invariably [supposed to be] IEEE 754 double-precision
binary floating-point format internally, as [the representations that I
have seen of] their internal formats are all in terms of sign, exponent,
and mantissa.

Although   typeof NaN    is "number", ECMA is clear that the type is
really 'Number' - but the value of NaN does not lie in the inclusive
range from -Infinity to +Infinity.

-- 
 (c) John Stockton, nr London, UK. ?@merlyn.demon.co.uk  Turnpike 6.05  WinXP.
 Web  <http://www.merlyn.demon.co.uk/> - FAQ-type topics, acronyms, and links.
 Command-prompt MiniTrue is useful for viewing/searching/altering files. Free,
 DOS/Win/UNIX now 2.0.6; see <URL:http://www.merlyn.demon.co.uk/pc-links.htm>.
0
reply1203 (8)
1/21/2012 8:27:30 PM
Reply:

Similar Artilces:

javascript within a javascript
Hello, I have a multi-frame page. The frames are named Frame_1, Frame_2 and Frame_3. Frame_1 has a drop down box. When a value is selected in this drop down box, Frame_2 is updated using an asp file (as I have to read from a back-end access database). In turn in the asp file, I have a Body onload tag to execute a javascript function within Frame_2. this function updates the contents of Frame_3. Till now this is working fine. Here is the problem. Frame_3 has a form with a radio button. When a radio button is selected, I want that a function be executed in Frame_3. However since conte...

Javascript and IE? Javascript and C#?
While my question might be simple, the environment around it is terribly messy and so I will try to keep this clear and simple by only including the relevant code - however, as I will soon suggest, I worry that the problem isnt in what would seem to be the relevant code but instead is lost somewhere in the do-and-donts of the peripheral code. So at the end, i'll try to include all the affected code and you can see if any of its actually relevant. I know there is a lot going on... sorry, but I tried to write this clearly. So here is what I imagine to be relevant. I'm working with a pa...

regex in javascript
Hi folks, I'm trying to learn and understand regex in javascript for web form validation. In trying to write a piece of script to validate an email address I came up with the following: function isEmail(input) { var re =/^\w([\.\-]\w)*@\w([\.\-]\w)+$/ if (!re.exec(input)) { return false } } This is then referred to as : if (!isEmail(document.form.mailfrom.value)) { alert("This does not look like an email address") } etc. Unfortunately it bombs on absolutely everything. Can anyone suggest why? As an aside, is there any trul...

dynamic load javascript from javascript
hi, from here: http://www.activewidgets.com/javascript.forum.6114.15/dynamic-load-javascript-from-javascript.html there is a method to load js from js, e.g. //--------------------------------------------------------------------------------------- var script = document.createElement('script'); script.type = 'text/javascript'; script.src = 'snip.js'; document.getElementsByTagName('head')[0].appendChild(script); //--------------------------------------------------------------------------------------- this method works great, but there is a bug(?) when using wit...

regex and Javascript
Hi - I've never tried using regular expressions with JS. Can someone help me with a simple one? I have a field that a user inputs that looks for an integer, or a some integers with a decimal then does some calculations and converts it to currency. Problem is, that if i have to recalculate, that field now has a "$" in it which throws off calculations. I'd like to look at the field and if there is a "$", strip it out, do the calculations, etc. So, something like: function getDollar() { myAmount = window.document.form.amount.value; //here is where i want to look f...

regEx in Javascript
Hi, I'm new to javascript and regEx and trying to solve the following problem. I have a function which validates the password if there is a number: ------------------------------------------------- function findNumeric(str_obj){ regEx = /\d/; if (str_obj.match(regEx)) return true; else return false; } -------------------------------------------------- The problem arises when I put a password with a space in between e.g: 'test test1'. The fucntion returns false. I've tried '\s' in the regEx but the user can put the space anywhere.. Any idea how to sol...

Javascript
Hello people, I'm trying to make a regional map in html and javascript, I'm sure how to d= o the following: to hover over the city, he should change the city's image with another clea= rer, and clicking in the city he should get a darker color than the picture= when we hover. Until there all right, but when I click it gets darker image and move the m= ouse in another city he immediately removes the dark image and return to th= e clearer picture. How to keep the image when I click on it and still the effect of passing th= e mouse? --------------------- the other t...

Javascript
Recently, I have had the role of being the Javascript guru at work. You know, one peeve I have about COLA is that it seems too oriented around client applications, when the the majority of the world is about Web applications. We talk about OO -- but javascript has always been there. As has DOM, and DHTML. A web developer is a fully OO programmer. In article <5%LCb.2953$Pg1.2136@newsread1.news.pas.earthlink.net> John Bailo <ten@lnilhtrea.oliabaj> wrote: >Recently, I have had the role of being the Javascript guru at work. For single man garage business, you sure have. ...

JavaScript
Guys, anybody know if is possible "to press" a button linked a javascript function using python? My Firefox send something like that: POST /msgs.aspx TOKEN=B8B83BGDBC191B9FE0A0BE1393294FAB&sig=gpaiOqbp0Nr %2BoecRLF4FGGDOAao %3D&toUserId=1331299&rawAddedDate=1188546666&fromUserId=23029&Action.delete=Send +data python has modules for forms and other things... and for it? Thank you for help... zowtar >python has modules for forms and other things... and for it? Check out httplib and urlib2, it might be useful for you. Hi! I know "how to", but o...

javascript
Cut'n'paste from "my" ticket 202 at www.ecomstation.com as they seem to have come to a halt... :-( ################################ Recenty I went from w4 fp17 to eCS 1.2. I get the odd behavior described beneath. Both boxes sees, and uses the same installations and user profiles. Clean install(s) of both Moz and FF has been done several times. Starting FF or Moz clean (no userprofiles), doesn't make any differnce. FIREFOX: The Weather extension i.e doesn't show it's 'mouseover' info, and it refreshes slow. Unit change which ...

JavaScript
If I have Options/ViewingMail/AllowExecutables unchecked does Eudora strip out the JavaScript? Or just refuse to execute it? TIA... Bob "Bob Bailey" <ebiz@usa.net> wrote in message news:rfOdnaRVycZZNzXenZ2dnUVZ_v-dnZ2d@rcn.net... > If I have Options/ViewingMail/AllowExecutables unchecked does Eudora strip > out the JavaScript? Or just refuse to execute it? OK. I've answered my own question but that begs a new one. (Eudora strips the JS.) Having allowed Executables it only works if I open, not preview, the message and then it insists on ope...

Javascript
Would anyone know whether Javascript works well with sound files? Tina Host wrote: > Would anyone know whether Javascript works well with sound files? Exactly as well as it works with files of any other type. -- |_ CJSonnack <Chris@Sonnack.com> _____________| How's my programming? | |_ http://www.Sonnack.com/ ___________________| Call: 1-800-DEV-NULL | |_____________________________________________|_______________________| ...

JavaScript
Javascript has it's own significance Amit Patel wrote: > Javascript has it's own significance Mr Patel, Stop using that stuff, it's bad for your brains. :P "Amit Patel" <amit2749@hotmail.com> wrote in message news:5f04ccb8.0401210427.3f93300c@posting.google.com... | Javascript has it's own significance It also has it's own group.. news:comp.lang.javascript ...

javascript
Hi all I wounder if some one can help me i have to write a program that sums numbe3rs together using a for loop. The numbers are 1 to 10 then one to 20 then 1 to 10,000. // A program for summing numbers from one to biggestNumber Var biggestNumber; Var theSum = 0; its got to start like this. Im having problems with this one viicki -- v davies Message posted via JavaKB.com http://www.javakb.com/Uwe/Forums.aspx/java-tools/200512/1 On Fri, 16 Dec 2005 11:27:29 GMT, "vicki via JavaKB.com" <u16404@uwe> wrote, quoted or indirectly quoted someone who said : >// A program fo...

Nixing Javascript via javascript: pseudoproto?
This is a question about defensive web browsing. Ocassionally I run into a page whose JavaScript does something that I find obnoxious. I would like to turn off JavaScript only for that page (instead of disabling it globally). It would be cool if there were some way to do this through a "bookmarkable" JavaScript snippet using the javascript: pseudoprotocol. Does anyone know any trick to do any of this? Many thanks! -bill "bill" wrote > This is a question about defensive web browsing. Ocassionally I > run into a page whose JavaScript does something that I fi...

javascript and []
<form name=f> <input type=text name="apple[]" value=1> </form> <script> document.f.apple[].value=2 </script> /////////////////////////// this generates an script error in IE because of apple[] so how do I get around the error? (must use "apple[]" for server cgi) thanks in advance :) document.getElementsByName("apple[]") //returns an object array -- www.vicdir.com <apple@apple.com> д���ʼ� news:ccpv0f$440$3@news.seed.net.tw... > <form name=f> > <input type=text name="apple[]" value=1> > <...

Javascript Caret Position in DIV
Hi All, I am looking for a way to get and set the caret position in an editable DIV. I have tried using the TextRange option, this is using the document.selection.createRange() function. The problem is that the TextRange object is sometimes shared in memory, and consequently one modification of the TextRange will affect another. I am using this to implement a javascript clipboard, so I have to be able to save the TextRange objects to restore any changes made to the DIV content when the user hits CTRL Z. Alternately, does anyone know of a good javascript clipboard? The default one does not ...

Including a javascript relative to its own location from another javascript
Hello, I want to include a javascript from another javascript. I know that I can do that by document.write("<script src='another.js'>"); I am exposing my main.js (which contains the above code) directly, intending it to be used via cross-site scripting (xss). In this case, the above code doesn't work. Because an external html which is using my main.js will look for another.js in its local directory. I have to change 'another.js' to '<absolute path>/another.js' for it to work. But now if I change the location of main.js I have to make chang...

tricky javascript problem requires javascript guru !
Hi, I am complete JavaScript novice and would really appreciate some help with this code: ===================================================================== <%@LANGUAGE="VBSCRIPT" CODEPAGE="1252"%> <!--#include file="Connections/ssdb.asp" --> <% Dim rs_news_edit Dim rs_news_edit_numRows Set rs_news_edit = Server.CreateObject("ADODB.Recordset") rs_news_edit.ActiveConnection = MM_ssdb_STRING rs_news_edit.Source = "SELECT * FROM tblnews" rs_news_edit.CursorType = 0 rs_news_edit.CursorLocation = 2 rs_news_edit.LockType = 1 r...

where are the javascripts?
On the link below: http://www.zytrax.com/books/dns/ I couldn't find the javascript codes (mouseover) needed for the Dynamic HTML menu at the top of the page. How did the site hide those codes? -- .~. Might, Courage, Vision. In Linux We Trust. / v \ http://www.linux-sxs.org /( _ )\ Linux 2.4.22-xfs ^ ^ 9:04pm up 2 days 11:31 load average: 1.08 1.20 1.08 toylet wrote: > On the link below: > > http://www.zytrax.com/books/dns/ > > I couldn't find the javascript codes (mouseover) needed for the > Dynamic HTML menu at the top of the page. How did the ...

JavaScript?
I have a question, and I hope this one hasn't been asked too frequently; if so, I apologize in advance. I've heard over time that it isn't a good idea to intermingle JavaScript with PHP code. Maybe that's a fallacy, and maybe not, but if so, would someone care to enlighten me as to why this might be the case? Thanks in advance for any responses. -- Randy Jackson http://fourcolorexplosion.com On Sat, 10 Jul 2004 16:32:43 GMT, Randy Jackson <randyjackson@ignorethispartfourcolorexplosion.com> wrote: >I have a question, and I hope this one hasn't been asked t...

assigning session a javascript value in javascript function
Hello Guyz.. I want to assign a varascript value to a session object in javascript function... like i have an image and onClick i am calling a function sort_(str).. Now i want to assign this value str to a session object in the same function... I know javascript code is client side and session is on server side.. but is there any way doing that?? function sort_(str) { document.ins_form.elements["Qry"].value = str; //alert(str); document.form1.submit(); } when i click on that image and that function calls everything works fine. but when i click on next to bring more records i c...

The JavaScript Planet! There are now 789 JavaScripts available
WELCOME to The JAVASCRIPT PLANET which is a page where I plan to publish as many JavaScripts (and maybe some other cool stuff like VRML, Animated GIFs) as possible, please contribute a JavaScript if you've got something useful. Just paste the code into the textbox and push the Send button! Your contribution will be published on a separate page, with your name and comment, within a week (usually). ...

Javascript with %%%%%%?
Hi,I had this guy post some spam to my site and now I'm on a mission tofind out who it is. He's got a site that redirects you elsewhere, inthat site I hit stop on the browser so I could see it. It containedthis script:SCRIPT type='text/javascript'>var ibnfbpy="%3c%73c%72%69pt%20"+""+"%74%79"+"p%65%3d%27%74ex"+"%74%2f%6a%61%76%61s%63%72%69%70%74%27%3e%0a%77i%6ed%6f%77%2e%6c%6f%63a%74%69%6fn%2e%68%72ef%3d%22%68t%74%70%"+"3a%2f%2f"+"%78%61%6e%61x%37%37%37"+"%70%69%6c%6c%73%2e%63o%6d%2f%71%2eph%"+&...