Link to home
Start Free TrialLog in
Avatar of BulldogMike
BulldogMikeFlag for United States of America

asked on

Date Input Validation and Translation in Lotus Notes

Hi

How would you approach this problem?  I need to translate a date entry in a form field into the standard MM\\DD\YY or MM\DD\YYYY format so  the user dosen't need to enter the slashes.  At the same time, I want to validate the entry so that alpha characters would be rejected.  Will the @Date function work here or do I need to write a script.  

Please advise

Thank you - Mike
Avatar of behenderson
behenderson
Flag of United States of America image

Well making the field of a Date type would force a valid date to be entered into it.  I am not sure that I understand fully the part about no slashes but if what I think you are saying is that instead of inputing 10/20/2010 you want them to be able to enter 10202010 and have the slashes put in for them there are a few problems.. 1112010 could be 1/11/2010 or 11/1/2010 so without some type of separator it does not really work.

WIthout knowing exactly what you want I would look at using the input validation portion of the field to put in something like

@If(@IsError(@TextToTime( Fieldname  )); @Failure("Please enter a date in this field" ); @Success)

Prior to that you could try the replace function to replace spaces with slashes if they are going to enter spaces instead of slashes so you would end up with

@ReplaceSubstring( Fieldname; " " : "." : "-"; "/" )

so the whole thing would look like
@If(@IsError(@TextToTime( @ReplaceSubstring( Fieldname; " " : "." : "-"; "/" )  )); @Failure("Please enter a date in this field" ); @Success)
BEWARE of "translating" dates!!!!

ALWAYS use a DATE field and apply the "formatting" to the field (normally you would use the users setting, which could also be as in my case: 2010-10-27)

that way you will never have issues "working" (exporting/calculating) with the date values.

If you start meddling around with "text" formatting of dates you will (almost guaranteed) encounter problems later as soon as you need to "work" with those values
Avatar of QuinF
QuinF

I guess I don't fully understand either.  Are the users entering the date into a field on a notes form?  If so, why not change the Style of the field from Notes Style to Calendar/Time Control.  That way the user just selects the date from a calendar and you're done.  Formatting is taken care of.
SOLUTION
Avatar of behenderson
behenderson
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of BulldogMike

ASKER

Thanks to everyone who responded to my question.  I learned something form all of you but I am not sure I aske the question properly to get the desired respones and will reward all of you with points if allowed
Thank You again
BulldogMike
 
Thanks again to eryone for your help