Validate get

Validate get

Postby DonDrew » Thu May 16, 2013 8: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.
DonDrew
 
Posts: 63
Joined: Mon Aug 02, 2010 5:38 pm

Re: Validate get

Postby Rick Lipkin » Thu May 16, 2013 9:59 pm

Don

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

Rick Lipkin

Code: Select all  Expand view

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


 
User avatar
Rick Lipkin
 
Posts: 2665
Joined: Fri Oct 07, 2005 1:50 pm
Location: Columbia, South Carolina USA

Re: Validate get

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

Re: Validate get

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

Re: Validate get

Postby FranciscoA » 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
User avatar
FranciscoA
 
Posts: 2158
Joined: Fri Jul 18, 2008 1:24 am
Location: Chinandega, Nicaragua, C.A.

Re: Validate get

Postby DonDrew » Fri May 17, 2013 1: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.
DonDrew
 
Posts: 63
Joined: Mon Aug 02, 2010 5:38 pm

Re: Validate get

Postby Antonio Linares » Fri May 17, 2013 8:31 am

Don,

What FWH version are you using ?
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 42092
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Re: Validate get

Postby DonDrew » Fri May 17, 2013 9: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()) }
DonDrew
 
Posts: 63
Joined: Mon Aug 02, 2010 5:38 pm

Re: Validate get

Postby nageswaragunupudi » Fri May 17, 2013 9:53 am

This is working for me:
Code: Select all  Expand view

#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
User avatar
nageswaragunupudi
 
Posts: 10632
Joined: Sun Nov 19, 2006 5:22 am
Location: India

Re: Validate get

Postby DonDrew » Fri May 17, 2013 10:08 am

There are 19 controls on this one dialog.
DonDrew
 
Posts: 63
Joined: Mon Aug 02, 2010 5:38 pm

Re: Validate get

Postby nageswaragunupudi » Fri May 17, 2013 2: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
User avatar
nageswaragunupudi
 
Posts: 10632
Joined: Sun Nov 19, 2006 5:22 am
Location: India


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: jmartial and 114 guests