Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Validating Entries In A TextBox
Message
 
To
17/10/2001 11:43:35
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Miscellaneous
Thread ID:
00569648
Message ID:
00569851
Views:
19
Instead of doing it in the data fields, do your validation when the
user clicks Save.

In your save routine, call a method to validate. This validation method
should return True/False, and the save method should decide to continue
saving based on that return value.

In the Validation routine, use this format:

LOCAL lRetVal, cMessage
lRetVal = .T.
cMessage = ""

 WITH ThisForm

  DO CASE
   CASE EMPTY(.txtMyField1.Value)
    cMessage = "The field 'MyField1' cannot be empty"
    .txtMyField1.SetFocus()

   CASE NOT BETWEEN(.txtMyField2.Value, nVal1, nVal1)
    cMessage = "The field 'MyField2' is invalid"
    .txtMyField2.SetFocus()

  ENDCASE

  IF NOT EMPTY(cMessage)
    MESSAGBOX(cMessage, 48, "Some Caption")
    lRetVal = .F.
  ENDIF

 ENDWITH

RETURN lRetVal
Everything makes sense in someone's mind
public class SystemCrasher :ICrashable
In addition, an integer field is not for irrational people
Previous
Reply
Map
View

Click here to load this message in the networking platform