Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.javascript > #8007

Data Validation Functions

From Gene Wirchenko <genew@ocis.net>
Newsgroups comp.lang.javascript
Subject Data Validation Functions
Date 2011-11-04 13:16 -0700
Organization A noiseless patient Spider
Message-ID <keh8b71001v4v80k2ejo0557v6b31i8vqb@4ax.com> (permalink)

Show all headers | View raw


Hello:

     I wish to validate data on a frontend.  One such validation is
whether the input string is a number.  I could parseInt() or
parseFloat(), but 1) I do not want to allow E-notation and 2) one form
of number that I want to check for is a dollar amount.

     Is there a function (or more than one) that does this, or do I
have to roll my own?

     If I do roll my own, one way to do it would be a regex.  Is this
a good idea?  What other alternatives are there?

     I am looking for a general answer to use.  I am not too concerned
with speed (unless a given way is way slower than others).  General,
bulletproof methods are nicer than those not.

     Assume that the parameter is a string.  I do not care what
happens if the parameter is null, undefined, or data of another type.
(Unless I should.  If so, why?)

     Pointers to Websites, in case this has all been covered before,
are welcome.

Sincerely,

Gene Wirchenko

Back to comp.lang.javascript | Previous | NextNext in thread | Find similar | Unroll thread


Thread

Data Validation Functions Gene Wirchenko <genew@ocis.net> - 2011-11-04 13:16 -0700
  Re: Data Validation Functions "Jukka K. Korpela" <jkorpela@cs.tut.fi> - 2011-11-04 22:42 +0200
    Re: Data Validation Functions Gene Wirchenko <genew@ocis.net> - 2011-11-04 14:04 -0700
  Re: Data Validation Functions Elegie <elegie@anonymous.invalid> - 2011-11-04 22:06 +0100
  Re: Data Validation Functions Denis McMahon <denismfmcmahon@gmail.com> - 2011-11-04 21:45 +0000
    Re: Data Validation Functions Gene Wirchenko <genew@ocis.net> - 2011-11-04 15:11 -0700
      Re: Data Validation Functions Elegie <elegie@anonymous.invalid> - 2011-11-04 23:40 +0100
        Re: Data Validation Functions Gene Wirchenko <genew@ocis.net> - 2011-11-04 16:11 -0700
          Re: Data Validation Functions Tim Streater <timstreater@greenbee.net> - 2011-11-04 23:26 +0000

csiph-web