Page 1 of 2
					
				Validate a field content if it is a date
				Posted: Thu Feb 18, 2010 8:57 pm
				by Joerg
				Hi,
I have a field, say txtDate, where I would like to validate whether the user has entered a valid date or not:
Code: Select all
set the useSystemDate to true
if fld txtDate is a date then put "true"
else put "false"
When I put a any number into the field then, say 1 or 123 or whatever, the validation results in "true" although it is not a valid date value. What am I doing wrong?
 
			
					
				Re: Validate a field content if it is a date
				Posted: Thu Feb 18, 2010 9:29 pm
				by BvG
				The "is a date" check is only checking if rev would convert the value to a date. Because of "the seconds", any integer is a date for rev. Every country enters date differently. So to make rev only accept valid dates, I suggest to check for formatting that are according to your local date requirements.
for example:
put field 1 into theDate
set the itemDe ... ans
end if
If you want to be sure I suggest to use a calendar entry widget that pops up, one like most websites use.
 
			
					
				Re: Validate a field content if it is a date
				Posted: Thu Feb 18, 2010 9:48 pm
				by Joerg
				Obviously I have misunderstood the "is a date" check. Thank you very much for your example. I think I will go with it. Although, using a calendar entry widget would maybe be the better alternative. Would it be possible for you to post a link of such a control because my search within revOnline Samples was not successful?
Thank you very much BvG
Jörg
			 
			
					
				Re: Validate a field content if it is a date
				Posted: Thu Feb 18, 2010 10:55 pm
				by dunbarx
				That rev can resolve an integer into a date can be both useful and annoying, as you have seen.
You can always say:
if fld "txtdate" is a date and fld "txtDate" is not an integer then...
Craig Newman
			 
			
					
				Re: Validate a field content if it is a date
				Posted: Thu Feb 18, 2010 11:05 pm
				by bn
				Jörg,
Sarah Reichelt has posted on her website a calender stack. This stack has a substack that lets you choose a date. 
http://www.troz.net/rev/index.irev?cate ... ity#stacks
Sarah knows all about dates and time in Rev. She is THE expert.
You have to test it, I did not include it in any of my projects yet, but she explains how to do it.
regards
Bernd
 
			
					
				Re: Validate a field content if it is a date
				Posted: Thu Feb 18, 2010 11:10 pm
				by BvG
				me too
http://www.bjoernke.com/?target=stacks
about in the middle, date & time
 
			
					
				Re: Validate a field content if it is a date
				Posted: Thu Feb 18, 2010 11:39 pm
				by bangkok
				
Damned ! I spent long time to modify Sarah's stack in order to make it as a group, not a popup window, for a revlet.
 
 
 
But your stack is perfect. I wish I had known it before.
 
			
					
				Re: Validate a field content if it is a date
				Posted: Fri Feb 19, 2010 1:01 am
				by BvG
				yeah... there should be a central repository where everyone uploads their stacks and hints and such... and then everybody would use it because it'd be rad and such... yeah that'd be nice... 

 
			
					
				Re: Validate a field content if it is a date
				Posted: Fri Feb 19, 2010 6:34 am
				by wsamples
				Hi. Altuit has a very nice date picker here:
http://www.altuit.com/webs/altuit2/RunRev/Downloads.htm
Look for altAnswerDate at the bottom of the page. It's very easy to insert and much more aesthetically neutral than the other ones I've seen.
 
			
					
				Re: Validate a field content if it is a date
				Posted: Fri Feb 19, 2010 10:27 am
				by Joerg
				Thanks to all! I think I will spend a bit of time to try the stacks. BvG, I think you are absolutely right with your suggestion that there should be a central repository. It would help definitely everybody! Craig, your "date-check", the combination of ... is a date ... and ... is not an integer ... is also a good approach but in my case a check of e.g. "14.123456" would result in "true" although this is not a date value is valid. But I think with additional checks (e.g. type of items and length) it would also work.
regards
Jörg
			 
			
					
				Re: Validate a field content if it is a date
				Posted: Fri Feb 19, 2010 11:10 am
				by bn
				@BvG,
you could post it to RevOnline, that could be a central repository. If only people would use it as such.
regards
Bernd
			 
			
					
				Re: Validate a field content if it is a date
				Posted: Fri Feb 19, 2010 11:13 am
				by BvG
				yes that's what i meant, rev online is there, but it has some backdraws. And the biggest is that people are not using it 

 
			
					
				Re: Validate a field content if it is a date
				Posted: Fri Feb 19, 2010 11:38 pm
				by malte
				Schnipp
Joerg wrote:... is not an integer ... is also a good approach but in my case a check of e.g. "14.123456" would result in "true" although this is not a date value is valid. But I think with additional checks (e.g. type of items and length) it would also work.
regards
Jörg
Schnapp
There also is the expression "is a number" which could be more useful in your case. Also for german dates you could set the itemdel to "." and check the number of items (which would need to be 3 and all of them would need to be numbers)
Cheers,
Malte
 
			
					
				Re: Validate a field content if it is a date
				Posted: Thu Feb 25, 2010 2:25 pm
				by SparkOut
				I like date picker stacks and have seen some good ones, but on Windows, Rev *still* cannot validate a date pre-1970. 
http://quality.runrev.com/qacenter/show_bug.cgi?id=4941 
			
					
				Re: Validate a field content if it is a date
				Posted: Thu Feb 25, 2010 2:43 pm
				by Klaus
				Hi folks,
on Windows you can use a tiny VBS Script as a workaround:
...
put "result = IsDate(" & QUOTE & the_date_in_question & QUOTE & ")" into tvb
do tvb as vbscript
put the result into is_a_date
## true or false
...
Tested with these (german! DD/MM/YYY) variations of a date:
01/01/1969
31/01/1969
31-01-1969
31.01.1969
31.01.69
01/01/69
31/01/69 ## Obvioulsy also works with english dates!
31-01-69
01/31/1969
31.1.69
Best
Klaus