Home > Ask the Domino Experts > Domino Development Questions & Answers > Using LS or JS to validate a date field on a Notes form
Ask The Domino Expert: Questions & Answers
EMAIL THIS

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

Andre Guirard EXPERT RESPONSE FROM: Andre Guirard

Pose a Question
Other Domino Categories
Meet all Domino Experts
Become an Expert for this site


Digg This!    StumbleUpon Toolbar StumbleUpon    Bookmark with Delicious Del.icio.us   


>
QUESTION POSED ON: 01 March 2004
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.


Digg This!    StumbleUpon Toolbar StumbleUpon    Bookmark with Delicious Del.icio.us   



RELATED CONTENT
Domino Development
Can I create and copy Microsoft Excel spreadsheets with LotusScript?
'Illegal circular use: Audit Trail' error when opening Lotus Notes docs
How to make computed fields recalculate
Sending and logging faxes from Lotus Notes and Domino
Accessing documents in a Lotus Notes database
Adding an action to the Lotus Notes right-click menu
Writing temporary text files that email as attachments
Trapping the on-click event of a radio button
Copying a form object using LotusScript
Connecting to a remote DB2 server with LEI

RELATED RESOURCES
2020software.com, trial software downloads for accounting software, ERP software, CRM software and business software systems
Search Bitpipe.com for the latest white papers and business webcasts
Whatis.com, the online computer dictionary



Search and Browse the Expert Answer Center
Search and browse more than 25,000 question and answer pairs from more than 250 TechTarget industry experts.
Browse our Expert Advice



Lotus Notes Domino on Blackberry and mobile devices
HomeTopicsITKnowledge ExchangeTipsAsk the ExpertsMultimediaWhite PapersDomino IT Downloads
About Us  |  Contact Us  |  For Advertisers  |  For Business Partners  |  Site Index  |  RSS
SEARCH 
TechTarget provides technology professionals with the information they need to perform their jobs - from developing strategy, to making cost-effective purchase decisions and managing their organizations' technology projects - with its network of technology-specific websites, events and online magazines.

TechTarget Corporate Web Site  |  Media Kits  |  Site Map




All Rights Reserved, Copyright 1999 - 2009, TechTarget | Read our Privacy Policy
  TechTarget - The IT Media ROI Experts