Page 1 of 1

Complex server side validation

PostPosted: 18 Sep 2017 16:38
by mrcarver
CG Gurus,

I have a need for server side validation of the CGEdit control. I have read everything I can find on the forum and still not figured it out.

Please advise

Regards
Monte Carver

Re: Complex server side validation

PostPosted: 18 Sep 2017 18:11
by Alexander Bulei
Hi mrcarver,

Please tell us your expected workflow for validation.

Best Regards.

Re: Complex server side validation

PostPosted: 18 Sep 2017 18:53
by mrcarver
I have a registration screen containing the classic First Name, Last Name, UserName, Password, etc.

As a simple example the password must meet a "complex" standard, which is already a Pascal defined library and not easily translated into a JQuery custom rule. In fact I don't currently even know how to create a custom rule.

Another example is ensuring the UserName does not already exist, which of course required a DB call.

t would be ideal if these server rules could be checked at same time a simple rule like "jqvorvRequired" is checked. But at a minimum would need checked prior to submittal.

The jQuery documentation refers to a REMOTE rule option but I have not discerned how to implement such feature.

Thank you for your quick attention.
Regards
Monte Carver

Re: Complex server side validation

PostPosted: 20 Sep 2017 09:25
by Alexander Bulei
Hi mrcarver,

Well, for the complex validations, I recommend you to check the validations on submit (on register button).

If you want check/run validations on-demand, you can implement the event OnBlur (occurs on focus out).

Best Regards.

Re: Complex server side validation

PostPosted: 20 Sep 2017 19:25
by mrcarver
Alexander,

I am trying to understand how to force a given control to given the same visual representation that it failed as is received from the browser based validation.

An example of a server side validation would be VERY helpful.

So for example something like the following which does not work:
Code: Select all
  with ePass0.JQValidateOptions do
  begin
    Enable:= True;
    Rules.Clear;
    lRule              := Rules.Add;
// HOW SHOULD THE RULE BE SET FOR A SERVER SIDE VALIDATION?
    lRule.Rule         := jqvorvRemote;
    lRule.ErrorMessage := 'Password is not complex.;


Code: Select all
procedure myPage.OnSubmit
begin
   if NOT fxIsPasswordComplex then
    begin
      ePass0.JQValidateOptions.IsValid := False;
      ePass0.JQValidateOptions.Validate;
    end;
end;


Please clarify what I am missing in my approach. Best I can tell I wish to implement the "REMOTE" feature referenced in the documentation:
https://jqueryvalidation.org/remote-method/

Re: Complex server side validation

PostPosted: 22 Sep 2017 09:22
by Alexander Bulei
Hi mrcarver,

Well, the remote validation doesn't work in this way, and we don't have support for that.
I'll analyze the possibility to implement/support that functionality in future.

Best Regards.

Re: Complex server side validation

PostPosted: 26 Sep 2017 09:24
by Alexander Bulei
Hi mrcarver,

Just FYI, I've added the new rule (remote) in 4.0.1.74.

Best Regards.