Re: Validate user input
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