ONJava.com -- The Independent Source for Enterprise Java
oreilly.comSafari Books Online.Conferences.


AddThis Social Bookmark Button
  Form Validation
Subject:   Phone validation in error
Date:   2003-08-01 15:11:16
From:   anonymous2
Response to: Phone validation in error

>> the phone script accepts alpha characters
>>Any ideas?

Perhaps try replacing:
if (isNaN(parseInt(stripped)))

with something along the lines of:
var filter = /^([0-9}{9})$/
if !filter.test(stripped)
{ error = "....." }

this should (theoretically anyways;) ) return true only if the (stripped) string contains 9 numbers only.

I am still learning JS, so any response (either confirmation or refutation) is welcomed.

Scott TFH