Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Javascript > numeric

Reply
Thread Tools

numeric

 
 
earl
Guest
Posts: n/a
 
      11-09-2003
arrDate = date.split('/');

How can I check if each array element contain only numeric values ?


 
Reply With Quote
 
 
 
 
Lasse Reichstein Nielsen
Guest
Posts: n/a
 
      11-09-2003
"earl" <> writes:

> arrDate = date.split('/');
>
> How can I check if each array element contain only numeric values ?


I assume you want them to be non-empty too (the empty string contains
only digits, all zero of them).

I would test before splitting, so you can get away with only one test.

If you know there must be exactly three parts, then try this:

if (!(/^\d+\/\d+\/\d+$/).test(date)) {
// error.
}

If you accept any number of parts, then
if (!(/^\d+(\/\d+)*$/).test(date)) {
// error.
}

/L
--
Lasse Reichstein Nielsen -
DHTML Death Colors: <URL:http://www.infimum.dk/HTML/rasterTriangleDOM.html>
'Faith without judgement merely degrades the spirit divine.'
 
Reply With Quote
 
 
 
Reply

Thread Tools

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

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
int to numeric numeric(18,2) ? jobs ASP .Net 2 07-22-2007 12:32 AM
Arithmetic overflow error converting numeric to data type numeric. darrel ASP .Net 4 07-19-2007 09:57 PM
check if string contains numeric, and check string length of numeric value ief@specialfruit.be C++ 5 06-30-2005 01:08 PM
Latches in pipeline design and numeric logic andyesquire@hotmail.com VHDL 3 04-06-2005 11:57 AM
SDBM_File Error: Argument "O_RDWR" isn't numeric in null operation Richard Perl 0 10-16-2003 02:46 PM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57