Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Validating a textbox field
Message
 
To
20/12/1997 18:23:20
General information
Forum:
Visual FoxPro
Category:
Forms & Form designer
Miscellaneous
Thread ID:
00067407
Message ID:
00067469
Views:
26
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 have a form in which I test for two items in a certain field:
>>
>>1. That the user has keyed in 8 characters
>>
>>2. That the last four characters are "7879"
>>
>>This is the code in the valid method of the textbox:
>>
>>** start - Valid method of textbox **
>>
>>al = len(wires.CUtransit) && create memory variable to
>>save to zzz all like al && see what VFP says is the length of expression
>>
>
>You must test here LEN(ALLTRIM(this.value)) as David Moore already said.
>
>>IF len(this.value)<>8
>>=messagebox("Transit Number must be 8 characters [ie. 12347879] !",16,oCUWS.appname)
>>else
>
>You don't need to test the length here. It has to be 8 because you're on the ELSE of <> 8.
>
>> if right(this.value,4)<>"7879" and len(this.value) = 8
>
>Why showing a message? If you already know that the last chars must be "7879", you can fix the value if it's wrong. Why force the user to type "7879" each time?

This field has a defualt value that very rarely will have to be changed - so this is not a big issue for them to make sure they are entering a value with the last four characters "7879"

>
>> =messagebox("Transit Number must end with '7879' !",16,oCUWS.appname)
>> endif
>>endif
>
>Vlad
Al Williams

Anola MB, CANADA
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform