Re: Validate user input
Re: Validate user input
- Subject: Re: Validate user input
- From: has <email@hidden>
- Date: Tue, 6 Nov 2001 20:29:24 +0000
Preston Smith wrote:
>
How do I confirm that a user has entered only numerals, or certain
>
punctuation marks, into a dialog box?
TIDs method:
======================================================================
set theString to "01252"
set validCharacters to "1234567890"
validateString(theString, validCharacters)
on validateString(theString, validCharacters)
copy theString to myText
set validCharsList to every item of validCharacters
set oldTIDs to AppleScript's text item delimiters
repeat with eachItem in validCharsList
set AppleScript's text item delimiters to eachItem as string
set myText to every text item of myText
set AppleScript's text item delimiters to ""
set myText to myText as string
end repeat
set AppleScript's text item delimiters to oldTIDs
if myText is not "" then error "Invalid characters found." number 1
theString
end validateString
======================================================================
HTH
has