Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Enforcing valid date into textbox
Message
From
06/03/2007 02:07:52
 
General information
Forum:
Visual FoxPro
Category:
Forms & Form designer
Miscellaneous
Thread ID:
01200381
Message ID:
01200944
Views:
31
By Returning 0 from valid you can show your
message i/o native vfp message

If you want to extend your validation to
more then one (only) valid method you can use
maybe folowing code sketch to enhance validation
on yr textbox class.
**Valid Method of TextBox
local ok,a,b,c &&etc
store .t. to ok, a,b,c...
this.valid_message=''
a=this.check_a() &&Validation Type1
b=this.check_b() &&Validation Type2
c=this.check_c() &&  .
.
.

&& Above valdations are writing nature of problem 
&&into property 'valid_message' which is later shown to user

ok =( a and b and c ...)
      
if !ok and lastkey() <> 27
    wait window this.valid_message nowait
    return 0
endif
return .t.

*User is blocked in the field til he/she complete or press esc
This way you can branch your validation process into
unlimited number of validation contributing methods.

There is more to it but this can give u general idea
I use wait wind to show validation message combined with label next to field changing color/caption. Depend on your need, user can be blocked or let continue entering even with wrong value and then stoped on central record validation/saving proc.

Being stucked all the time inside msgbox dialog can be annoying for user.
hth


>>>How do I enforce a valid date on a textbox. The textbox is defined as char at the moment and in the init= thisform.textbox1.value=DATE() and
>>>thisform.textbox1.Format='D' . However, I can enter bogus dates.
>>
>>If Value is date type then you cannot enter bogus values. Make sure you don't override value back to character. To find it easier remove 'D' format.
>
>Ed, how do I make the VFP message appear on a form as a popup? This is for when the user enters a bogus date in the field. I am trying to go this route:
>
>SET MESSAGE TO [cMessageText]-or-SET MESSAGE TO [nRow [LEFT | CENTER
> | RIGHT]]-or-SET MESSAGE WINDOW [WindowName]
>
>but no message appears.Will this work for VFP standard default messages?
*****************
Srdjan Djordjevic
Limassol, Cyprus

Free Reporting Framework for VFP9 ;
www.Report-Sculptor.Com
Previous
Reply
Map
View

Click here to load this message in the networking platform