Jump to content

Valitation Form


Sebastiao Purcini

Recommended Posts

Hi.

- In property "Script", of the MainForm I add "Ext.QuickTips.init();";

- In the fields, I add "allowBlank=false" on afterRender (ExtEvents);

function afterrender(sender, eOpts)
{
  sender.allowBlank = false;
}

- Then validation for required fields is apply on exit. It's ok ;

 

So, I need validate all fields, but, on click the button.

 

(Sorry, I don't put images in post).

Link to comment
Share on other sites

  • 4 months later...

 

Now I need to abort the query post when there are required fields to fill. Example:

void __fastcall TMainForm::qryLoginBeforePost(TDataSet *DataSet)
{
	// This would be the function using
	// UniSession->AddJS(this->WebForm->JSForm->JSName + ".isValid()");
	if(!isValid())
	{
		Abort();
	}
}

 

 

I'm having the same problem.

I need to get if the edit is valid like Edit1.IsValid.

Is there any way to get the isValid()?

 

Hi there. 

 

You must use AjaxEvent for this but keep in mind that this validation is only on clientSide.

The correct is to have the validation on server side too.

 

On ClientEvents.UniEvents (beforeInit) of Edit component:

function beforeInit(sender, config)
{
  Ext.apply(sender,{allowBlank:false,vtype:'email'});
}

On ClientEvents.ExtEvents (validitychange) of Edit component:

function validitychange(sender, isValid, eOpts)
{   
   ajaxRequest(sender, 'Valida', ['isValid='+isValid] );   
}

OnAjaxEvent of Edit component:

 

void __fastcall TUniForm1::edtEmailAjaxEvent(TComponent *Sender, UnicodeString EventName,
  TUniStrings *Params)
{
    if (EventName == "Valida")
    {
        // this is a private variable
        EmailValido = (Params->Values["isValid"] == "true"); 
    }
}

On ClientEvents.ExtEvents (click) of Button component:

function click(sender, e, eOpts)
{
   // this will validate all components in your form
   sender.uform.isValid();
}
OnClick of Button component:
void __fastcall TUniForm1::UniButton2Click(TObject *Sender)
{
    if (EmailValido)
    {
        ShowMessage("Validação realizada com sucesso!");
    }
    else
    {
        ShowMessage("Erro ao validar campos obrigatórios.");
    }
}

Best regards

Link to comment
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
×
×
  • Create New...