• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag
 

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Validate user input
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Validate user input


  • Subject: Re: Validate user input
  • From: Paul Skinner <email@hidden>
  • Date: Wed, 07 Nov 2001 14:23:24 -0500

on 11/6/01 2:24 PM, AppleScripter wrote:

>> How do I confirm that a user has entered only numerals, or certain
>> punctuation marks, into a dialog box?
>
> There have been a couple of good posts with good scripts. If the "certain
> punctuation marks" are just a period and a comma, then you could probably do
> this a lot easier than looping through every character. Just force a
> coercion and trap the error. This is untested:
>
> display dialog "Type in a number:" default answer ""
> set validateMe to the text returned of the result
>
> try
> set validatedNumerics to validateMe as real --or integer or number depending
> on error
> display dialog "Not a number. Please try again."
> end
>
> Greg Strange

This works well except for strings containing 'e' or 'E'.

--
Paul Skinner


References: 
 >Fw: Validate user input (From: "AppleScripter" <email@hidden>)

  • Prev by Date: Re: Adding AETE resource
  • Next by Date: Trouble saving Quark Doc after getting file path.
  • Previous by thread: Fw: Validate user input
  • Next by thread: Re: Validate user input
  • Index(es):
    • Date
    • Thread