HOW TO make my own JS validation on form submission event?

Talk and info about common issues

Moderator: alexandrleonenko

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

HOW TO make my own JS validation on form submission event?

Postby administrator » Mar 21st, '09, 11:39

The DataGrid already includes the definition of JavaScript function, named onSubmitMyCheck(), so...

You just need to write this function anywhere at the top of your page and this function will be called automatically when you submit your updates in Edit mode.

For example, if you want to give for user some additional message:

Code: Select all

<script>
 function unique_prefix_onSubmitMyCheck(){
   alert("Remember .............!!!");
   return true;
 }
</script>
</head>


Also if you want to check your own fields, that is not a part of DataGrid fields or make additional checks:

Code: Select all

<script>
 function unique_prefix_onSubmitMyCheck(){
   if(document.getElementById('ID').value =''){
       alert("Please check .............!!!");
        return false;
   }else{
        return true;
   }
}
</script>
</head>


TIPS:
- unique_prefix_ - is unique prefix of your DataGrid defined in $unique_prefix = 'abc_';
- To know what is ID of checking element just open HTML source of the page and find needed textbox, textarea etc. Generraly ID of every element will be looked like this: "id='rtylast_name" or in other words: ID = "req_type" + field name

Return to “ApPHP DataGrid {HOW TO}”