Validate get

Post Reply
DonDrew
Posts: 63
Joined: Mon Aug 02, 2010 5:38 pm

Validate get

Post by DonDrew »

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.
User avatar
Rick Lipkin
Posts: 2397
Joined: Fri Oct 07, 2005 1:50 pm
Location: Columbia, South Carolina USA

Re: Validate get

Post by Rick Lipkin »

Don

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

Rick Lipkin

Code: Select all

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.)
 


 
DonDrew
Posts: 63
Joined: Mon Aug 02, 2010 5:38 pm

Re: Validate get

Post by DonDrew »

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.
User avatar
cnavarro
Posts: 5792
Joined: Wed Feb 15, 2012 8:25 pm
Location: España

Re: Validate get

Post by cnavarro »

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
C. Navarro
Hay dos tipos de personas: las que te hacen perder el tiempo y las que te hacen perder la noción del tiempo
Si alguien te dice que algo no se puede hacer, recuerda que esta hablando de sus limitaciones, no de las tuyas.
User avatar
FranciscoA
Posts: 1964
Joined: Fri Jul 18, 2008 1:24 am
Location: Chinandega, Nicaragua, C.A.

Re: Validate get

Post by FranciscoA »

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.

Fwxh1204-MySql-TMySql
DonDrew
Posts: 63
Joined: Mon Aug 02, 2010 5:38 pm

Re: Validate get

Post by DonDrew »

valid ( empty(cSS_Num ) )

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

Both versions return False regardless of what may be entered by the user.
User avatar
Antonio Linares
Site Admin
Posts: 37481
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain
Contact:

Re: Validate get

Post by Antonio Linares »

Don,

What FWH version are you using ?
regards, saludos

Antonio Linares
www.fivetechsoft.com
DonDrew
Posts: 63
Joined: Mon Aug 02, 2010 5:38 pm

Re: Validate get

Post by DonDrew »

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()) }
User avatar
nageswaragunupudi
Posts: 8017
Joined: Sun Nov 19, 2006 5:22 am
Location: India
Contact:

Re: Validate get

Post by nageswaragunupudi »

This is working for me:

Code: Select all

#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
DonDrew
Posts: 63
Joined: Mon Aug 02, 2010 5:38 pm

Re: Validate get

Post by DonDrew »

There are 19 controls on this one dialog.
User avatar
nageswaragunupudi
Posts: 8017
Joined: Sun Nov 19, 2006 5:22 am
Location: India
Contact:

Re: Validate get

Post by nageswaragunupudi »

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
Post Reply