Subject Re: Reqired fill
From Ken Mayer <dbase@nospam.goldenstag.net>
Date Tue, 1 Jun 2021 13:35:41 -0700
Newsgroups dbase.getting-started

On 6/1/2021 1:26 PM, Ken Mayer wrote:
> On 6/1/2021 12:59 PM, charlie wrote:
>> Sorry...  Here is the code:
>>
>> if len(form.entryfield4.value) < 5
>>            msgbox( " Sorry" )
>>             form.auctopen1.rowset.fields["locate_a"].value = ""
>>         endif
>>
>> Doesn't seem to work.
>
> onChange only fires after the user exits the entryfield, first off. So
> it doesn't fire as they type (good thing).
>
> When you create the form, and you set the picture, a value is also set,
> even if you empty the value in the inspector, it is set to "  -  " --
> hence, the length is *always* five ... The problem is that onChange will
> still let you move off the entryfield. If you use valid, it forces the
> user to enter the correct number of digits.
>
> Using valid is a much better tool for this if the user ** MUST ** enter
> the correct number of digits, the only concern is that they may not be
> able to do anything else, including abandon the rowset changes ... See
> attached form ...

Note that I used trim() which would deal with missing digits to the
right of the dash, you could add ltrim( trim ... to the code, to deal
with missing digits on the left of the dash ...

Ken


--
*Ken Mayer*
Ken's dBASE Page: http://www.goldenstag.net/dbase
The dUFLP: http://www.goldenstag.net/dbase/index.htm#duflp
dBASE Books: http://www.goldenstag.net/dbase/Books/dBASEBooks.htm
dBASE Tutorial: http://www.goldenstag.net/dbase/Tutorial/00_Preface.htm
dBASE Web Tutorial: http://www.goldenstag.net/dbase/WebTutorial/00_Menu.htm