HighDots Forums  

Re: Integer Check

Javascript JavaScript language (comp.lang.javascript)


Discuss Re: Integer Check in the Javascript forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
Dr John Stockton
 
Posts: n/a

Default Re: Integer Check - 04-20-2004 , 02:48 PM






JRS: In article <200420040733235484%denmarks (AT) domain (DOT) invalid>, seen in
news:comp.lang.javascript, Dennis M. Marks <denmarks (AT) domain (DOT) invalid>
posted at Tue, 20 Apr 2004 07:33:23 :

Quote:
What is the best way to validate a field as a positive or negative
integer?
How about a zero one? Do you want to allow a floating-point form of a
value which happens to be integer, such as 1e6 or 3.000 ? How about
0xFF ?

OK = /^[+-]?\d+$/.test(field)
tests for optional sign followed by only decimal digits. \d{1,6} might
be preferred, likewise [+- ] .

See <URL:http://www.merlyn.demon.co.uk/js-valid.htm>.

--
© John Stockton, Surrey, UK. ?@merlyn.demon.co.uk Turnpike v4.00 IE 4 ©
<URL:http://jibbering.com/faq/> Jim Ley's FAQ for news:comp.lang.javascript
<URL:http://www.merlyn.demon.co.uk/js-index.htm> jscr maths, dates, sources.
<URL:http://www.merlyn.demon.co.uk/> TP/BP/Delphi/jscr/&c, FAQ items, links.


Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.