Jump to content

Field Validation In Tabular Report Page


Recommended Posts

I need to ensure that values in a column in a tabular report are between 0 and 100 (They are meant to be a percentage impact figure to be entered by the user). I studied the JS example of creating column totals in a tabular report (see http://forums.caspio.com/index.php/topic/3171-js-calculate-column-sum-in-the-result-page/ ) and modified the code as follows, but I cannot get the script to fire at all. I added a number of debugging statements to no avail. I have tried an "onsubmit" type of call as well, apart from the below example. Ideally there should be a way to fire this at the end of adding / editing each row, but I could live with at the end of  the whole page as well. 

 
At the end of the Header:
<div id="cb_checkImpact">
 
 
At the beginning of the Footer:
</div>
<script>
function f_check() 
{
  alert('Inside function');
   var v_impact = 0;
   var cas_form = document.getElementById("cb_checkImpact");
   if (cas_form.getElementsByTagName("table").length > 0) 
   {
      alert('Found records');
      var cas_rows = cas_form.getElementsByTagName("table")[1].getElementsByTagName("tr");
      for(var rowIndex=1; rowIndex < cas_rows.length; rowIndex++) 
      {
        alert('Inside row loop');
         var cells = cas_rows[rowIndex].getElementsByTagName("td");
 
         /* 1 – change value inside brackets to choose column to perform validation */
         v_impact = cells[2].innerHTML;
         alert('Found value:');
         alert(v_impact);
         if ( parseFloat(v_impact) < 0 || parseFloat(v_impact) > 100){
            alert('Value in %Impact field must be between 0 and 100');
            return(false);
         }
         alert('No issues found');
      }
}
alert('About to call function');
f_check();
alert('Finished function');
</script>
 
Link to post
Share on other sites

Hello Niranjan,

 

Is the "100" allowed?

If not, you can go to the "Editing" tab and in the "Character length: Max:" field enter "2". Then user can enter only numbers from 0 to 99.

 

Does it work for you?

Link to post
Share on other sites
  • 10 months later...

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...