Sebastiao Purcini Posted November 9, 2017 Share Posted November 9, 2017 Hi folks! I'm doing a validation in the fields of the form, using "Ext.QuickTips.init();" and "allowBlank=false", in Ext Events. This is works on exit, but, how can I use in the event "onclick" of the button ? Link to comment Share on other sites More sharing options...
Sherzod Posted November 9, 2017 Share Posted November 9, 2017 Hi, Give us some of your code, how you do it Best regards, Link to comment Share on other sites More sharing options...
Sebastiao Purcini Posted November 9, 2017 Author Share Posted November 9, 2017 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 More sharing options...
Sherzod Posted November 9, 2017 Share Posted November 9, 2017 Hi, Ok, one of the possible solutions I think, try this: procedure TMainForm.UniBitBtn1Click(Sender: TObject); begin UniSession.AddJS(Self.WebForm.JSForm.JSName + '.isValid()'); end; Best regards, Link to comment Share on other sites More sharing options...
Sebastiao Purcini Posted November 9, 2017 Author Share Posted November 9, 2017 Perfect man, I need exactly this. One more question.. for function "isValid()", I could some return value for abort "Post" of the query? Link to comment Share on other sites More sharing options...
Sherzod Posted November 9, 2017 Share Posted November 9, 2017 I could some return value for abort "Post" of the query? Can you explain, what you wanted ?! Link to comment Share on other sites More sharing options...
Sebastiao Purcini Posted November 9, 2017 Author Share Posted November 9, 2017 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(); } } Link to comment Share on other sites More sharing options...
SMARAM Posted March 29, 2018 Share Posted March 29, 2018 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()? Link to comment Share on other sites More sharing options...
Sherzod Posted March 29, 2018 Share Posted March 29, 2018 Hi, On the client side? Link to comment Share on other sites More sharing options...
SMARAM Posted March 29, 2018 Share Posted March 29, 2018 Hi, On the client side? Server Side. I want to check on the click of a button. Link to comment Share on other sites More sharing options...
naozuka Posted March 29, 2018 Share Posted March 29, 2018 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 More sharing options...
Recommended Posts
Please sign in to comment
You will be able to leave a comment after signing in
Sign In Now