Q

Using LS or JS to validate a date field on a Notes form

Is there a way using LotusScript or perhaps JavaScript to validate a date field on a Notes form? Users will occasionally manually enter a date like 11/18/0200 and the form stills saves successfully. There is a date control on the field to pick a date; however, many times they manually enter the data. Any suggestions would be greatly appreciated. Thank you! I generally prefer to use macro language for validation, but you can use any...

of these languages. JavaScript is the hardest because its default way of handling dates is not identical to the way Notes does it. Here's an example macro language validation formula:

@If(@ThisValue = ""; 
"You must enter a date"; 
@Year(@ThisValue) < 1950; 
"Please enter a date no earlier 
than 1950 A.D."; 
@Success) 
Or, in a Querysave form event, you might do something like this:
Sub Querysave(Source As 
NotesUIDocument, 
Continue As Variant) 
Dim doc As NotesDocument 
Set doc = Source.Document 
If doc.DateField(0) = "" Then 
msgbox "You must enter a date." 
Source.GotoField "DateField" 
Continue = False 
Elseif Year(doc.DateField(0)) < 1950 
msgbox "You must enter a date 
no earlier than 1950." 
Source.GotoField "DateField" 
Continue = False 
End If 
End Sub 

Perhaps you can see why I prefer macro language.

Do you have comments on this Ask the Expert Q&A? Let us know.

This was first published in March 2004

Dig deeper on LotusScript

Have a question for an expert?

Please add a title for your question

Get answers from a TechTarget expert on whatever's puzzling you.

You will be able to add details on the next page.

0 comments

Oldest 

Forgot Password?

No problem! Submit your e-mail address below. We'll send you an email containing your password.

Your password has been sent to:

-ADS BY GOOGLE

SearchWinIT

Search400

  • iSeries tutorials

    Search400.com's tutorials provide in-depth information on the iSeries. Our iSeries tutorials address areas you need to know about...

  • V6R1 upgrade planning checklist

    When upgrading to V6R1, make sure your software will be supported, your programs will function and the correct PTFs have been ...

  • Connecting multiple iSeries systems through DDM

    Working with databases over multiple iSeries systems can be simple when remotely connecting logical partitions with distributed ...

SearchEnterpriseLinux

SearchVirtualDataCentre.co.UK

Close