Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

validating hour

Status
Not open for further replies.

fishman13

Programmer
Jul 8, 2002
73
US
I have a form that has a control box used to store a time. The box is set with an input mask of 99:99. Is there a way to determine if a valid time is entered or do I need to convert the field to a date time. I was currently trying to use val(this.value), but only the hours are being checked.
 
i haven't tested this but you may want to try. in the control's valid event, put the ffg. code:

Code:
local okhr, okmin

okhr = iif(between(val(left(this.value,2)), 0,23), .t., .f.)
okmin = iif(between(val(right(this.value,2)), 0,59), .t., .f.)

if okhr and okmin
     [do valid]
else
     [do invalid]
endif

kilroy [trooper]
philippines
"and that's what we call creativity..."
 
this maybe help :

In the Valid Procedure of the textbox


Code:
if empty(ctot(this.value))
  return .F.
endif

If u enter an valid time, i mean Hour 0~23,min 0~59,sec~059. It will return a valid datetime else CTOT(this.value) will return nothing. Where this.value is Character.

Code:
?ctot("23:59:59") &&(valid time)
?ctot("24") &&(invalid hour,empty)
?ctot("23:60") &&(invalid hour,empty)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top