• 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: Help with validating a date input to a dialog
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Help with validating a date input to a dialog


  • Subject: Re: Help with validating a date input to a dialog
  • From: Michelle Steiner <email@hidden>
  • Date: Fri, 30 Mar 2001 19:53:37 -0800

On 3/30/01 7:29 PM, Michelle Steiner <email@hidden> wrote:

>*nod* It's going to be for me and a friend of mine who uses the standard
>US date/time format. I do plan to do more error trapping for format,
>though, but this one can catch a lot of the errors right off the bat and
>save me from writing a lot of the trapping.

Here it is.

--Michelle

global DateToSend
display dialog (my setthedate("Please enter the date in format
"mm/dd/yyyy"."))

on setthedate(prompt)
set errorPrompt to "Please us the correct format "mm/dd/yyyy"."
set DateToSend to (text returned of (display dialog prompt default
answer ""))
set {tid, AppleScript's text item delimiters} to {AppleScript's text
item delimiters, "/"}
try
date DateToSend
on error
my setthedate(errorPrompt)
end try
set the itemsToCheck to the text items of DateToSend
set checkMonth to text item 1 of itemsToCheck as number
if checkMonth is greater than 12 or checkMonth is less than 1 then
setthedate(errorPrompt)
end if
set checkDate to text item 2 of itemsToCheck
if checkDate is greater than 31 or checkDate is less than 1 then
setthedate(errorPrompt)
end if
set checkyear to text item 3 of itemsToCheck
if length of checkyear is not 4 then
setthedate(errorPrompt)
end if
set text item delimiters to tid
return DateToSend
end setthedate

----------------------------------------------------------------------
| Michelle Steiner | We're not human beings having a spiritual |
| | experience. We're spiritual beings |
| email@hidden | having a human experience. |
----------------------------------------------------------------------


  • Prev by Date: Re: Help with validating a date input to a dialog
  • Next by Date: Re: Help with validating a date input to a dialog
  • Previous by thread: Re: Help with validating a date input to a dialog
  • Next by thread: Re: Help with validating a date input to a dialog
  • Index(es):
    • Date
    • Thread