Solved

validate inputbox to see if the field entered is a date field

Posted on 2006-06-27
11
1,104 Views
Last Modified: 2013-12-18
Hi,

I've a lotusscript agent, that asks for user input: the user should input date only.

xStatusIdate$ = Inputbox("Please enter a valid Inactive Until Date in the following format: MM/DD/YYYY.")            
                Dim datetime As notesdatetime
                Dim datetime1 As notesdatetime
      Set datetime=New notesdatetime(xStatus$)
      Set datetime1=New notesdatetime(Now)
      If Cdat(datetime.dateonly) <=  Cdat(datetime1.dateonly) Then
                      Messagebox "Inactive Until Date should be greater than today's
                      date.",,"distribution tier1 database"
                      Exit Sub
                End If                        

How do i force the user to input the data in MM/DD/YYYY format.
I've to also check if the user is inputting the field in date format only.
or can i've a popup box with a date drop down to select?

please advise
thanks
sri
0
Comment
Question by:sridevi911
  • 3
  • 3
  • 2
  • +1
11 Comments
 
LVL 63

Accepted Solution

by:
SysExpert earned 50 total points
ID: 16996078
You can use a popup Calendar, change the field to Date/TIme, and choose the Calendar control as the style.

The Second Tab will allow you tochoose formatting.

I hope this helps !
0
 

Author Comment

by:sridevi911
ID: 16996094
can you please provide a lotusscript example for calender control style.

thanks
0
 

Author Comment

by:sridevi911
ID: 16996116
oh by the way this is an input box. not a form entry field in the actual form.
this value in the inputbox will be saved into a date field in the form.
hope i'm clear.
0
 
LVL 43

Expert Comment

by:Steve Knight
ID: 16997062
You could check the format using a LIKE operation, i.e. something like

if xStatusIDate$ LIKE "##[/]##[/]####" then
   Process date...
else
   ask again...
end if

But I think you'd be better off just converting it to a date and see if you get an error or using IsDate(xStatusIdate$) to check it is a valid formatted date.

Steve
0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
LVL 18

Expert Comment

by:marilyng
ID: 16997721
Just a quick comment - input boxes are rather awkward tools to present to end users.  

Questions: is there some reason why you have user's entering a date in an input box rather than on the form itself?
 --Then do as sysExpert suggests and make the field on the form an OS calendar style field, and set it to collect a date only.  Then in the input translation, you can set the format, and in the validation events, check to be sure the date is later than today's date.

As sysexpert suggests, far easier than writing a bunch of script.

----------------
If you wanted to write a bunch of script, then you should create a small form with that one OS Calendar Control field on it, with the same name as the field on the form.   If you have a button that does: @DialogBox, it will present the dialog box.  YOu can keep it open until the user enters a correct date, and when they do and don't click cancel, the dialog box closes and populates the field with the new date.

---Again, no fancy script .  Check @DialogBox in  Developer Help, and "Creating a graphical display for Date/Time fields" "Calendar/Time control."  << you don't need  lotus script to display the control. :)
 
---
Another fun tool: Embedding a date picker  
0
 
LVL 43

Expert Comment

by:Steve Knight
ID: 16998538
I would go for a Dialog box as marilyng suggested too if I were writing an app for end users to be honest - it's much neater and less prone to user error.

Steve
0
 

Author Comment

by:sridevi911
ID: 17001358
hi i understand about the dialogbox.

but let me explain you the situation here.
this is a big agent that has lot of other code. the user will basically click on a button in a parent document and will change the status to inactive.
so when the status of the parent document is changed to inactive, the agent has lot of other code to change the child documents to inactive status too.

one part of the code is this inputbox. when the user changes the status to inactive, it will ask for inputting a valid date.
now, i guess i can do two things here.  one validate it using
If xStatusIDate$ LIKE "##[/]##[/]####"    or
completely get away from inputbox and use the dialogbox method.
I cannot use formula language here since there is lot of other code in here.

can you please suggest me some examples of dialog box method to show a pop up calender.

thanks
0
 
LVL 18

Assisted Solution

by:marilyng
marilyng earned 50 total points
ID: 17005727
Plenty of samples in Designer Help!  

-------------------------------

flag = notesUIWorkspace.DialogBox( form$ , [autoHorzFit] , [autoVertFit] , [noCancel] , [noNewFields] , [noFieldUpdate] , [readOnly] , [title$] , [notesDocument] , [sizeToTable] , [noOkCancel] , [okCancelAtBottom] )


So you instantiate the dialog box document
set doc = uidoc.document
set dialogdoc = db.createdocument
with dialogdoc
   ' prefill with any essential information that you want
   .form = "thisForm"
   .another field = doc.thisOtherField(0)
   .computewithform false, false
end with
 
Dim result as variant
set result = ws.dialogbox("thisForm",true, true,true,true,false,false,"Here is a dialog box",dialogdoc, true)
'Boolean. Returns True if the user clicks OK in the dialog box. Returns False if the user clicks Cancel.
if not result then exit sub

----------------------

'Now the nice thing is that in the dialog box you can not let the user press OK until they've entered a correct date.

The input box you'd have to try and specify the format, and then you're limited at best with instructions.  Spend some time in designer help.. good example
0
 
LVL 43

Expert Comment

by:Steve Knight
ID: 17006921
Dialog boxes make nice professional looking app IMHO and much better idea than parsing text to check dates.  They are redicuously easy in formula and not exactly complicated in script, once you have one drawn up with proper form colours and table layout etc. a new dialog takes minutes to bang out. Have a play :-)
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

You’ve got a lotus Domino web server, and you have been told that “leverage browser caching” is a must do. This means that we have to tell the browser everywhere in the web to use cache. In other words, we set (and send) an expiration date in the HT…
For beginners of Lotus Notes user this is important to know about the types of files and their location supported by IBM Notes. Mostly users are unaware about how many file types are created and what their usages are. This Article is fully dedicated…
This video shows how to remove a single email address from the Outlook 2010 Auto Suggestion memory. NOTE: For Outlook 2016 and 2013 perform the exact same steps. Open a new email: Click the New email button in Outlook. Start typing the address: …
When you create an app prototype with Adobe XD, you can insert system screens -- sharing or Control Center, for example -- with just a few clicks. This video shows you how. You can take the full course on Experts Exchange at http://bit.ly/XDcourse.

948 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now