sez "Chipp Walters" <[EMAIL PROTECTED]>:
Thanks Richard,

While your script works fine for numbers, it can't easily validate
email addresses, social-security numbers, zip codes, etc.. I really
need a single place I can put all this validation stuff, as the
project I'm working on has over 50 different input screens.
Looking at Richard's original script, it seems to me that there's at least one semi-obvious way to go...

on keyDown k
  put false into LetItPass
  put the length of the target into TargLen
  switch (the uValidationType of the target)
  case "integer"
     if k is in "0123456789" then put true into LetItPass
     break

  case "zipcode"
     # 5-digit ZIPs: 5 digits
     # 9-digit ZIPs: 5 digits, 1 dash, 4 digits
     if TargLen = 6 then
        # the user is typing the *6th* char, which must be a dash
        if k is "-" then put true into LetItPass
     else if TargLen < 11 then
        # the user is typing any other char, which much be a digit
        if k is in "0123456789" then put true into LetItPass
     end if
     break

  case "socialsecurity"
     # 3 digits one dash, 2 digits, 1 dash, 4 digits; total of 11 chars
     if ((TargLen = 3) or (TargLen = 6)) then
        # the user is typing either the 4th or 7th char;
        # either way, it's gotta be a dash
        if k is "-" then put true into LetItPass
     else if TargLen < 12 then
        # any other char in the string, it's a digit
        if k is in "0123456789" then put true into LetItPass
     end if
     break

  case "complicated"
# this particular class of input needs a highly complex validation scheme if ThisComplexValidator (k, (the target)) then put true into LetItPass
     break

  default
     put true into LetItPass
     # if you want to be fussy about input validation,
     # *don't* put true into LetItPass by default; rather,
     # leave LetItPass alone

  end switch

  if LetItPass then pass keyDown
end keyDown

  Hope this helps...
________________________________________________________________________
AOL now offers free email to everyone. Find out more about what's free from AOL at AOL.com.
_______________________________________________
use-revolution mailing list
use-revolution@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-revolution

Reply via email to