FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin for Harbour/xHarbour Validate get
Posts: 63
Joined: Mon Aug 02, 2010 05:38 PM
Validate get
Posted: Thu May 16, 2013 08:13 PM

REDEFINE GET oSS_Num VAR cSS_Num ID 2103 of oFld:aDialogs[GenFldr] ;
Picture "@R ###-##-####" ;
valid ( !empty(cSS_Num ) ) ;
UPDATE

Need to be sure that the user can't save a blank value to cSS_Num. This used to work just fine in earlier versions of my system before I upgraded FWH/Harbour.

Is there a better way of testing for an empty field? I've oSS_Num:VarGet() and oSS_Num:Value() both methods test as empty.

Posts: 2706
Joined: Fri Oct 07, 2005 01:50 PM
Re: Validate get
Posted: Thu May 16, 2013 09:59 PM
Don

I would do your validation this way .. gives you more options ..

Rick Lipkin

Code (fw): Select all Collapse
REDEFINE GET oSS_Num VAR cSS_Num ID 2103 of oFld:aDialogs[GenFldr] ;
Picture "@R ###-##-####" ;
valid ( _ChkSsn( cSs_num,oSs_num )) UPDATE


//--------------
Static Func _ChkSsn( cSs_num,oSsn_num )

Local Saying

If empty( cSs_num ) .or. cSs_num = "  "
   Saying := "SSN is a Required field"
   MsgInfo( Saying )
   oSs_num:SetFocus()
   Return(.f.)
Endif

Return(.t.)
Posts: 63
Joined: Mon Aug 02, 2010 05:38 PM
Re: Validate get
Posted: Thu May 16, 2013 10:27 PM

I did a poor job of describing my problem.

Since upgrading the FWH\Harbour the valid statement always finds cSS_Num empty, regardless of whatever the user may enter.

Posts: 6755
Joined: Wed Feb 15, 2012 08:25 PM
Re: Validate get
Posted: Thu May 16, 2013 10:38 PM
DonDrew wrote:REDEFINE GET oSS_Num VAR cSS_Num ID 2103 of oFld:aDialogs[GenFldr] ;
Picture "@R ###-##-####" ;
valid ( !empty(cSS_Num ) ) ;
UPDATE

Need to be sure that the user can't save a blank value to cSS_Num. This used to work just fine in earlier versions of my system before I upgraded FWH/Harbour.

Is there a better way of testing for an empty field? I've oSS_Num:VarGet() and oSS_Num:Value() both methods test as empty.


VALID ( if (empty(cSS_Num ) , .F., .T. )) ;
So I work my
Cristobal Navarro

Hay dos tipos de personas: las que te hacen perder el tiempo y las que te hacen perder la noción del tiempo

El secreto de la felicidad no está en hacer lo que te gusta, sino en que te guste lo que haces
Posts: 2170
Joined: Fri Jul 18, 2008 01:24 AM
Re: Validate get
Posted: Thu May 16, 2013 11:13 PM

Hi,
I do the same as Mr. Rick, with something more:

The more secure method I have found to validate gets, it's when you press the "Accept" button, of the dialogue.

Why?, because if you have 3 gets, for example, and the user clicks the "Accept" button while him is in the second get, el third will be not evaluated.
Regards.

Francisco J. Alegría P.

Chinandega, Nicaragua.



Fwxh-MySql-TMySql
Posts: 63
Joined: Mon Aug 02, 2010 05:38 PM
Re: Validate get
Posted: Fri May 17, 2013 01:03 AM

valid ( empty(cSS_Num ) )

valid ( if(empty(cSS_Num ),.F.,.T.) )

Both versions return False regardless of what may be entered by the user.

Posts: 44158
Joined: Thu Oct 06, 2005 05:47 PM
Re: Validate get
Posted: Fri May 17, 2013 08:31 AM

Don,

What FWH version are you using ?

regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 63
Joined: Mon Aug 02, 2010 05:38 PM
Re: Validate get
Posted: Fri May 17, 2013 09:05 AM

Hi, Antonio.

FWH Ver 13.03

I found the solution this morning.

These did not work:
valid( !empty(cSS_NUM) )
valid( !empty(oSS_Num:Value()) )

This DID work:
oSS_Num:bvalid := { !empty(oSS_Num:Value()) }

Posts: 10733
Joined: Sun Nov 19, 2006 05:22 AM
Re: Validate get
Posted: Fri May 17, 2013 09:53 AM
This is working for me:
Code (fw): Select all Collapse
#include "fivewin.ch"

function Main()

   local cVar  := Space( 8 )
   local oGet
   local oDlg

   DEFINE DIALOG odlg

   @ 10,10 GET oGet VAR cVar PICTURE "@R ###-##-###" SIZE 50,12 PIXEL OF oDlg ;
      VALID !Empty( cVar )

   @ 25,10 BUTTON "ok" SIZE 30,14 PIXEL OF oDlg

   ACTIVATE DIALOG oDlg CENTERED

   ? cVar

return nil

The get is validated when the focus is moved from the get object to another control of the dialog. The above program is working correctly as expected.

Get validation is not executed when there is only one get on the dialog.

The original code in the first posting should work as it is and as expected if there is another control on the dialog.
Regards



G. N. Rao.

Hyderabad, India
Posts: 63
Joined: Mon Aug 02, 2010 05:38 PM
Re: Validate get
Posted: Fri May 17, 2013 10:08 AM

There are 19 controls on this one dialog.

Posts: 10733
Joined: Sun Nov 19, 2006 05:22 AM
Re: Validate get
Posted: Fri May 17, 2013 02:08 PM
DonDrew wrote:There are 19 controls on this one dialog.

#1. Can you please compile and test the small program I posted and give your feedback if that is working as expected?

#2. Then if you still have problem, please post a small sample to reproduce your problem. A complete sample that we can compile and test at our end here. That will greatly help us to help you.
Regards



G. N. Rao.

Hyderabad, India

Continue the discussion