onSubmitMyCheck not working!

Discuss everything related to ApPHP DataForm. All versions. Any questions related to the ApPHP DataForm developing or using should be posted to this forum.

Moderator: alexandrleonenko

nkd
Junior
Junior
Posts: 22
Joined: Apr 15th, '11, 22:37

onSubmitMyCheck not working!

Postby nkd » Oct 24th, '11, 16:07

I implemented the onSubmitMyCheck() js function for extra validation of fields as the documentation says. The problem is that even though I return FALSE if the validation fails, the form submits and proceeds to preview mode.

How can I stop the submission of the form if the validation I implemented fails??

nkd
Junior
Junior
Posts: 22
Joined: Apr 15th, '11, 22:37

Re: onSubmitMyCheck not working!

Postby nkd » Oct 24th, '11, 16:17

Checking the generated HTML of my page I have:

Code: Select all

function sendAddFields(pass_mode){
            var result_value = true;       
            if(window.onSubmitMyCheck){ if(!onSubmitMyCheck()){ result_value = false; } }  result_value = _dfUpdateWysiwygFieldsIE('', true);     
            if(result_value == true && jsFormValidator.onSubmitCheck(document.frmDataForm, true, false, '.')){
                document.getElementById('mode').value = pass_mode;
                document.frmDataForm.submit();
            }else{
                false;
            }
      }


It looks like the result_value is being afected by the result_value = _dfUpdateWysiwygFieldsIE('', true); part of the code which I dont know what it does but I think thats the problem. How can I solve it? Its kind of urgent.

Thanks

nkd
Junior
Junior
Posts: 22
Joined: Apr 15th, '11, 22:37

Re: onSubmitMyCheck not working!

Postby nkd » Oct 24th, '11, 16:33

Yes. That was the problem. I modified the dataform.class.php near line 3825 to echo onSubmitMyCheck AFTER the _dfUpdateWysiwygFieldsFF (which I dont know what it does, but it should not be after the validation changing the value of "result_value").

This is the second bug I find in two days of using the script. Makes me wonder if it was even tested... I biught it ti save some time in developing but I am spending more time debugging than anything else. I liked the css designs of the forms but the script seriously needs some hard work. I have like 100 feature requests if you are interested.

administrator
Site Admin
Site Admin
Posts: 6010
Joined: Jan 7th, '09, 23:18
Contact:

Re: onSubmitMyCheck not working!

Postby administrator » Oct 25th, '11, 07:51

Thank you for your help. This issue will be fixed in the next version.
To fix it manually do following:

1. find

Code: Select all

if(window.".$this->uniquePrefix."onSubmitMyCheck){ if(!".$this->uniquePrefix."onSubmitMyCheck()){ result_value = false; } } ";

and replace it with

Code: Select all

var on_submit_my_check = true;
if(window.".$this->uniquePrefix."onSubmitMyCheck){ if(!".$this->uniquePrefix."onSubmitMyCheck()){ on_submit_my_check = false; } } ";


2. find :

Code: Select all

if(result_value == true && jsFormValidator.onSubmitCheck(document.".$this->uniquePrefix."frmDataForm, ".$this->jsValidationErrors.", false, '.')){

and replace it with

Code: Select all

if(result_value == true && on_submit_my_check == true && jsFormValidator.onSubmitCheck(document.".$this->uniquePrefix."frmDataForm, ".$this->jsValidationErrors.", false, '.')){

nkd
Junior
Junior
Posts: 22
Joined: Apr 15th, '11, 22:37

Re: onSubmitMyCheck not working!

Postby nkd » Oct 26th, '11, 10:26

Just to let you know that on your instructions, in the first step, the code you ask me to search and the code I am supposed to replace it with, are exactly the same. Must be a typo.

administrator
Site Admin
Site Admin
Posts: 6010
Joined: Jan 7th, '09, 23:18
Contact:

Re: onSubmitMyCheck not working!

Postby administrator » Oct 27th, '11, 08:37

Sorry, fixed - please check again.

chirng
Master
Master
Posts: 149
Joined: Jun 7th, '09, 04:15

Re: onSubmitMyCheck not working!

Postby chirng » Nov 26th, '13, 03:30

is there any sample for using onSubmitMyCheck? I would like to know how to apply it to check a date entry.


chirng
Master
Master
Posts: 149
Joined: Jun 7th, '09, 04:15

Re: onSubmitMyCheck not working!

Postby chirng » Nov 26th, '13, 09:14

I affair it may not working on ApPHP DataForm Pro version 3.3.9 also, because I tested recently, please advise.

TQ

administrator
Site Admin
Site Admin
Posts: 6010
Joined: Jan 7th, '09, 23:18
Contact:

Re: onSubmitMyCheck not working!

Postby administrator » Nov 27th, '13, 08:29

Here the example:

Code: Select all

<script type='text/javascript'>
     function unique_prefix_onSubmitMyCheck(){
          alert('Ok!'); return true;
     }   
</script>


where "unique_prefix_" is a prefix defined for your dataform.


Return to “ApPHP DataForm”