Re: validating a date in hstools?
Posted in 1994
Topics: General Discussion
Charlie, Jim's comments are correct, but you'll quickly become exasperated if you don't include a AND LENGTH(date_val) > 0; the ABORT EXIT is pretty literal and will force a good date to be input once the field is entered, even if the user presses the CANCEL button. David jvr@informix.com (Jim Van Riper) writes: >Charlie: >Validating a date is pretty easy and like most things in HST, >there are a couple of ways to do it. Here is the easiest. > If you want to let them type willy nilly any legal date, > attach a script similar to the following psuedo-code (that > means I havent tested it!) to the field in question. > DEFINE date_val > ON EXIT > date_val = CTSTRING("date_field",0) > IF DATEVALUE(date_val) = 0 { bad value? Try it } > SOUND EFFECT "simple beep" > ABORT EXIT { dont let them leave } > END IF > END EXIT > This should work although you may have to verify the value again > when they OK the dialog. As noted above, Im not sure what the > value/type DATEVALUE returns when you give it an illegal value. >Have fun, >jvr