VALIDATE

<< Click to Display Table of Contents >>

Navigation:  General Functions > Configuring the MIE (Programmer's Guide) > Portal Design > Request Portal Design (Programmer's Guide) > Template Construction >

VALIDATE

The {%VALIDATE%} tag is used to insert javascript that will be used to perform client-side validation of data that is input by the user.  The Request Portal includes ESI's javascript library, which includes several routines for performing validation.  Many of the routines have a "DIV" variation, in which the DIV that contains the control whose value is to be validated is passed to the routine.  The routine performs validation only if the containing DIV is currently visible.

Generally, the validation javascript is written as a single routine that returns true if all validation checks pass, false otherwise.

The syntax is as follows:

{%VALIDATE~~<javascript for performing validation>%}

 

Example:

{%VALIDATE~~

<script type="text/javascript" language="javascript">
<!--
function Validate() {
if(testforRequiredDIV('divWorkstation','SRPWksDevID550','Asset # or Device ID')==false){return(false);}
if(testOptionDIV('divSRPSvrReqType550','SRPSvrReqType550','Server Request Type')==false){return(false);}

return(true);
}
-->
</script>

%}

 

NOTE:  The Request Portal includes two additional validation routines that may be called when moving from one step to another in the wizard.  The validate routines are used to test Questions and Answers, and are defined as follows:

Pre-defined Javascript Validation Function

Definition

CheckQuestionnaires()

Checks the current Shopping Cart for entries, and then checks to see if any Shopping Cart entry has associated questions and, if so, if answers have been provided.  The routine returns false if any Shopping Cart item for which questions have been defined is missing answers, true otherwise.  

QAValidate()

Performs validation of the current Q&A area based on the settings as defined for the Request Questions.  Returns false if any validation rule does not pass.  Returns true otherwise.

 

Example of call to Q&A validation (performed only when on the wizard step that handles Q&A).  This code is inserted into the template within the VALIDATE area, and specifically within the Validate() javascript function, such that these functions are also called as part of the call to Validate():

//check the Q&A - check for individual entries if visible currently. Q&A is step 3
//also check to make sure that all questionnaires have been answered
 
if(GetControlValue('StepCurrent553')==3){
 if(QAValidate()==false){return(false);}
   if(CheckQuestionnaires()==false) {
     alert('You must complete all questionnaires before continuing');
     return(false);
 }
}