Form_CustomValidate: how to refer rows in fobj.element

Hello all
PHPMaker 2020.0.12 here.

I Have a grid add page (but also for grid edit)
where in Client-side Form_CustomValidate I’m asked to:

  1. calculate the total for column field1 (could assume alternatively negative or positive value)
  2. check if this total field1 is = 0, negative or positive, and alert the customer accordingly
  3. check on the same row if value of field1 is different from field2

example:

row1 field1: -16
row1 field2: 216

row2 field1: 20
row2 field2: 731

total field1: 4
total field2: 947

does anybody know how to navigate the fobj.elements in javascript/jQuery ?

I found in the Help file at Server Events and Client Scripts
Table-Specific → Form_Customvalidate:
“If you need to access fields in other rows, either use fobj.elements or jQuery with CSS selectors.”

But I don’t know how to work with the specific row (say 1, 2 whatever…)


Can you please help?

thanks in advance
regards
jta

Instead of using client-side, you may actually use “Grid_Inserting” server event to validate all the rows.

Please read “Server Events and Client Scripts” topic from PHPMaker Help menu, for more info and example.

Instead of using client-side, you may actually use “Grid_Inserting” server event to validate all the rows.
Please read “Server Events and Client Scripts” topic from PHPMaker Help menu, for more info and example.

thank you mobhar for your reply.
I actually followed the way you suggest. But I wasn’t able to arrange a CONFIRMATION step before inserting/updating.
This is the reason why I was planning to migrate the checks on Client-side.

Could you possibly suggest how to put up a CONFIRMATION step on Grid_Inserting/Updating event?
(I saw the CONFIRM option is present in Add and Edit Page but I don’t seem to find in Grid Add/Grid Edit of List Page)

thanks again and regards
jta

Unfortunately, Grid-Add and Grid-Edit mode does not support confirmation page just like single Add and Edit page.

Unfortunately, Grid-Add and Grid-Edit mode does not support confirmation page just like single Add and Edit page.

ok mobhar, thank you.

So, again, can you please give a hint on how to work (in javascript/jQuery) with fobj.elements and referring to a specific row (say 1st, 2nd…) ?

thanks and regards
jta

You may actually refer to the generated Javascript code in the List Page that contains/enables Grid-Add and Grid-Edit mode, which at least one of the fields/columns in that Grid uses “Required” option setting from “Fields” setup → “Validation”.

You will see in the generated *list.php file, the Javascript validation code that generated by PHPMaker. Hopefully that would help you.

You will see in the generated *list.php file, the Javascript validation code that generated by PHPMaker. Hopefully that would help you.

Yes, THAT did the trick! thank you very much for your help.

regards
jta