Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Validating a textbox field
Message
 
To
21/12/1997 13:18:24
General information
Forum:
Visual FoxPro
Category:
Forms & Form designer
Miscellaneous
Thread ID:
00067407
Message ID:
00067485
Views:
23
>>Thanks, I've changed the code as follows:
>>
>>IF len(alltrim(wires.CUtransit))<>8
>>=messagebox("Transit Number must be 8 characters [ie. 12347879] !",16,oCUWS.appname)
>>return 0
>>else
>> if right(wires.CUtransit,4)<>"7879"
>> =messagebox("Transit Number must end with '7879' !",16,oCUWS.appname)
>> return 0
>> endif
>>endif
>>
>>My problem now is that the user can't do anything unless the field has 8 characters and the last four characters are "7879". I want the user to have the ability to cancel the transaction without having this field correctly filled in. What do I have to change to make this possible.
>
>I still don't understand why you show a message when the string doesn't end with "7879". You could have a 4 char entry field and "fix" the string in the valid code by adding the "7879" suffix.
>
>Jim Booth gave the solution for your problem: You should have a cancel button on the form with the Cancel property set to .T. and at the begging of your validation method:
>
>IF LASTKEY() = 27 && Escape
> RETURN .T.
>ENDIF
>
>This will allow the user to press Escape to cancel or... and this is the nice part, click on the Cancel button.
>
>BTW, when returning from a validation/when procedure, you can use RETURN .T. or RETURN .F. instead of RETURN 1/RETURN 0. Although it works, these methods are supposed to return a logical and not a numerical value. The code becomes more clear this way.
>
>Vlad


Vlad, Thanks for the advice. I've decided to go with your suggestion and have the user enter the first four characters in that field and have "7879' added programatically.

However, you have lost me with your advice in using the code the code "if lastkey . . ." Specifically, where does this code go? And what cancel "property"

Thanks, AL
Al Williams

Anola MB, CANADA
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform