﻿<!--
/********** CLIENT VALIDATION FUNCTIONS  ******************************************************/	
/*
Note 1: All function validate data only if there are data in it 
    so if you want to make it mandatory you have to call also to ValidateFieldMandatory function

You can call the validation function for example using a button:
    OnClientClick="return validateAndPrepareForm()" 
    
//********************************* start JS FOR VALIDATIONS *********************************************
function FormatMandatoriesField() {
    //Add in here all the field that will appear with a mandatory image in the browser
        //FormatMandatoryField("Email");
        //UnFormatMandatoryField("Email") 
        //...
}

VerifyRecursivelyMandatoryFields();//Needed to create images in mandatory fields first time

function validateAndPrepareForm() {
    strMsg = '';
    FieldsToChangeStyles = '';

    // Hide message label not needed
        //HideMsgLabel ('msgLabel');
        //...

    // Fields to validate. 
   	    //ValidateFieldMandatory (document.form1.Email, '<%= (string)HttpContext.GetGlobalResourceObject("L10N", "lblEmail") %>') ;	
   	    //ValidateFieldNumeric (document.form1.YearFounded, '<%= (string)HttpContext.GetGlobalResourceObject("L10N", "lblYearFounded") %>') ;	
        //ValidateFieldLength (document.form1.QualityAssuranceProcesses, 500, '<%= (string)HttpContext.GetGlobalResourceObject("L10N", "lblQualityAssuranceProcesses") %>') ;	
   	    //ValidateFieldCustom ('Email',document.form1.Email, '<%= (string)HttpContext.GetGlobalResourceObject("L10N", "lblEmail") %>') ;	
   	    //ValidateFieldCustom ('Phone',document.form1.EmergencyPhone, '<%= (string)HttpContext.GetGlobalResourceObject("L10N", "lblEmergencyPhone") %>') ;	
        //ValidateFieldCustom ('URL',document.form1.URL, '<%= (string)HttpContext.GetGlobalResourceObject("L10N", "lblURL") %>') ;	
  	    //ValidateFieldCustom ('URL',document.form1.FTPAddress, '<%= (string)HttpContext.GetGlobalResourceObject("L10N", "lblFTPAddress") %>') ;	
   	    //ValidateCustomFunction (BoolCommentIsMandatoryWithOther(),document.form1.Comment , '<%= (string)HttpContext.GetGlobalResourceObject("L10N", "lblComment") %>','<%= (string)HttpContext.GetGlobalResourceObject("L10N", "lblCommentIsMandatory") %>') ;	
        //...
        
    //This is a message show in an extra label at the botton of the page
        //ShowValidationMsgIfNeeded (0,'errorLabel2');
    
    //This is a message show in a label and in an alert.
    if (ShowValidationMsgIfNeeded (1,'errorLabel')){return false;} else {return true;}
}
//********************************* end JS FOR VALIDATIONS *********************************************


/*** Main Validation functions ****
function ValidateFieldMandatory(fieldName,fieldText) 
        //Format the validation message if textbox is empty
        //Example:     	ValidateFieldMandatory (document.form1.Email, '<%= (string)HttpContext.GetGlobalResourceObject("L10N", "lblEmail") %>') ;	
function ValidateFieldLength(fieldName,fieldLength,fieldText) 
        //Format the validation message checking length of a textbox
        //Example:    	ValidateFieldLength (document.form1.AdditionalInformation, 500, '<%= (string)HttpContext.GetGlobalResourceObject("L10N", "lblTitleAdditionalInfo") %>') ;	
function ValidateFieldBetween2Length(fieldName,fieldLengthFrom,fieldLengthTo,fieldText) 
    //Format the length between 2 textbox
function ValidateFieldsAreTheSame(fieldName1,fieldName2,fieldText1,fieldText2) {
    //Ensure Password and ConfirmPassword are the same
function ValidateFieldNumeric(fieldName,fieldText) 
        //Format the validation message allowing only numeric values in the textbox
        //Example:    	ValidateFieldNumeric (document.form1.YearsOfExperience, '<%= (string)HttpContext.GetGlobalResourceObject("L10N", "lblYearFounded") %>') ;	
function ValidateFieldCustom(CustomFieldType, fieldName,fieldText) 
        //Format the validation message according to several formats
        //Example:      ValidateFieldCustom ('Email',document.form1.Email, '<%= (string)HttpContext.GetGlobalResourceObject("L10N", "lblEmail") %>') ;	
        //CustomFieldType accept values:
            -> 'Email':
            -> 'URL':
            -> 'Phone' also valid for Fax:
function ValidateCustomFunction(boolShowMsg, fieldName,fieldText,ValidationMsg) 
	    //It is used to allow the use of any custom function that return a boolean
	    //Example:     	   	ValidateCustomFunction (BoolCommentIsMandatoryWithOther(),document.form1.Comment , ' (string)HttpContext.GetGlobalResourceObject("L10N", "lblComment") ',' (string)HttpContext.GetGlobalResourceObject("L10N", "lblCommentIsMandatory") ') ;	


*/
        
/*** Main Format functions ****
function ShowValidationMsgIfNeeded (showAlert,errorLabel)
    // Show validation messages within an errorLabel and in a javascript message
       The error message comming from strMsg is going to be show:  
        Enter(int)showAlert = 1 will show a javascript message, 0 no
             (string)errorLabel = name of a label where is going to show the message. If empty or not a valid label will not show anything
             (string)strMsg = error message to be show
        Exit: Boolean true if there are error and false if not.
function ShowStylesInFields(){
    //Format the style for ALL FIELDS
function FormatValMessage(fieldName,fieldText, MessageToAdd)
    //Format the validation message for ALL FIELDS
function FormatValMessageForExplanation(fieldName,fieldText, MessageToAdd)
    //Add Validation message for explanation if errors
    //Value is added to FormatValMessage if this is show
    //No field is formated

/*** Auxiliary Validation functions ****
function checkEMAIL(fieldName) 
        //check whether or not it is valid email
function checkURL(fieldName)
        //check whether or not it is valid HTTP, HTTPS or FTP
function correctHttp(fieldName) 
    //add http by default to URL fields
function checkPhone(fieldName)
    International phone number check 
    Validates on the following standards: +CCC.ZZZZZZZZZZxYYYY, where 
    'C' is the numeric country phone code (up to three digits), 
    'Z' is the phone number (up to 12 digits) and 
    'Y' is the extension (up to 4 digits); 
    max length overall is 20 characters, including the '+', '.', and 'x' (if extension is present). 
    Matches +800.4453377x4444 | +80.4453377 | +8.123456789123x1111 
    Non-Matches 181823884499 | +800.4453377x | 2486994x11 
function correctPhone(fieldName) 
    //update phone fields removing leading, trailing and interior spaces       
function TrimInteriorSpaces(value) 
function EmptyData(data)
       //Boolean true/false if is an empty field
function checkNumeric(strString)
       //check for valid numeric strings	
function HideMsgLabel(msgLabel) 
       //Hide messages label not needed
function FormatMandatoryField(fieldName) 
        //Add a background image to mandatory fields
function UnFormatMandatoryField(fieldName) 
        //Remove image from fields
function VerifyRecursivelyMandatoryFields()
        //It is called it itself recursively to all mandatory fields
function VerifyRecursivelyMandatoryFieldsFnc(functionNameToCall)
        //It is called it itself recursively to all mandatory fields
*/
/****************************************************************/	
/****************************************************************/		

/****************************************************************/		
/*
	Enter: 
	Exit: 
*/
function ValidateFieldMandatory(fieldName,fieldText) {
    //Format the validation message is textbox is empty
    if ((typeof(fieldName) == "undefined") || (fieldName == null) ) {return '';}
    
    switch (fieldName.type) {
			case 'text': 
                if (EmptyData(fieldName.value))
                    return FormatValMessage (fieldName, fieldText, MsgFieldMandatory);
                else
                    {
                    fieldName.style.borderColor = "";
                    return ''
                    }
				break;
			case 'checkbox': 
                if (! fieldName.checked){
                    //Color is not working in Firefox
                    fieldName.style.borderStyle = "Solid";
                    fieldName.style.borderWidth = "2px";
                    return FormatValMessage (fieldName, fieldText, MsgFieldMandatory);
                    }
                else
                    {
                    fieldName.style.borderStyle = "";
                    fieldName.style.borderColor = "";
                    return ''
                    }
				break;
			case 'select-one': 
                if (fieldName.value == '-1'){
                    fieldName.options[fieldName.selectedIndex].style.color = "red";
                    fieldName.options[fieldName.selectedIndex].text = MsgSelectValue;
                    return FormatValMessage (fieldName, fieldText, MsgFieldMandatory);
                    }
                else
                    {

                    return ''
                    }
				break;
			case 'select-multiple': 
                if (fieldName.options.length >0){
                    fieldName.style.borderStyle = "";
                    fieldName.style.borderColor = "";
                    return ''
                    }
                else
                    {
                    //Color is not working in IE
                    fieldName.style.borderStyle = "Solid";
                    fieldName.style.borderWidth = "1px";
                    fieldName.style.borderColor = "red";
                    return FormatValMessage (fieldName, fieldText, MsgFieldMandatory);
                    }
				break;
			default:
                if (EmptyData(fieldName.value))
                    return FormatValMessage (fieldName, fieldText, MsgFieldMandatory);
                else
                    {
                    fieldName.style.borderColor = "";
                    return ''
                    }
	        break;
		}
		
}

/****************************************************************/		
/*
	Enter: 
	Exit: 
*/
function ValidateFieldLength(fieldName,fieldLength,fieldText) {
    //Format the validation message checking length of a textbox
    if ((typeof(fieldName) == "undefined") || (fieldName == null) ) {return '';}
    if (fieldName.value.length > fieldLength)
        return FormatValMessage (fieldName, fieldText, MsgLongerThan + fieldLength);
    else
        {
        fieldName.style.borderColor = "";
        return ''
        }
}

/****************************************************************/		
/*
	Enter: 
	Exit: 
*/
function ValidateFieldBetween2Length(fieldName,fieldLengthFrom,fieldLengthTo,fieldText) {
    //Format the length between 2 textbox
    if ((typeof(fieldName) == "undefined") || (fieldName == null) ) {return '';}
    if (((fieldName.value.length) > 0) && ((fieldName.value.length < fieldLengthFrom) || (fieldName.value.length > fieldLengthTo)))
        return FormatValMessage (fieldName, fieldText, msgPasswordLength);
    else
        {
        fieldName.style.borderColor = "";
        return ''
        }
}

//****************************************************************/		
/*
	Enter: 
	Exit: 
*/  
function ValidateFieldsAreTheSame(fieldName1,fieldName2,fieldText1,fieldText2) {
    //Ensure Password and ConfirmPassword are the same
    if ((typeof(fieldName1) == "undefined") || (fieldName1 == null) ) {return '';}
    if ((typeof(fieldName2) == "undefined") || (fieldName2 == null) ) {return '';}
    if (fieldName1.value != fieldName2.value)
        return FormatValMessage (fieldName2, fieldText1 + strEndField + ' & ' + strInitField +  fieldText2 , msgAreNotTheSame);
    else
        {
        fieldName2.style.borderColor = "";
        return ''
        }
}

/****************************************************************/		
/*
	Enter: 
	Exit: 
*/
function ValidateFieldNumeric(fieldName,fieldText) {
    //Format the validation message allowing only numeric values in the textbox
    if ((typeof(fieldName) == "undefined") || (fieldName == null) ) {return '';}
	fieldName.value = fieldName.value.replace(',','.');
	if ((!(checkNumeric(fieldName.value))) || (fieldName.value == '.'))
        return FormatValMessage (fieldName, fieldText, MsgNumberNotOK);
    else
        {
        fieldName.style.borderColor = "";
        return ''
        }
}

/****************************************************************/		
/*
	Enter: ValidateCustomFunction. It is used to allow the use of any custom function that return a boolean
	Exit: 
*/
function ValidateCustomFunction(boolShowMsg, fieldName,fieldText,ValidationMsg) {
    if ((typeof(fieldName) == "undefined") || (fieldName == null) ) {return '';}
    if (boolShowMsg)
        return FormatValMessage (fieldName, fieldText, ValidationMsg);
    else
        {
            if ((fieldName != null) && (fieldName != ''))
                fieldName.style.borderColor = "";
        return ''
        }
}
/****************************************************************/		
/*
	Enter: CustomFieldType accept values 'Email', 'URL', 'Phone'
	Exit: 
*/
function ValidateFieldCustom(CustomFieldType, fieldName,fieldText) {
    //Format the validation message according to several formats
    if ((typeof(fieldName) == "undefined") || (fieldName == null) ) {return '';}
    switch (CustomFieldType) {
			case 'Email': //Format for email Textbox
	            if ( ((fieldName.value.length) > 0) && (!(checkEMAIL(fieldName))) )
                    return FormatValMessage (fieldName, fieldText, MsgEmailNotOK);
                else
                    {
                    fieldName.style.borderColor = "";
                    return ''
                    }
				break;
			case 'URL': //Format for URL Textbox. Is valid for HTTP, HTTPS or FTP
	            if ( ((fieldName.value.length) > 0) && (!(checkURL(fieldName))) ){
                    return FormatValMessage (fieldName, fieldText, MsgURLNotOK);
                    }
                else
                    {
                    fieldName.style.borderColor = "";
                    return ''
                    }
				break;
			case 'Phone': 
			    // International phone number  
	            if ( ((fieldName.value.length) > 0) && (!(checkPhone(fieldName))) )
                    return FormatValMessage (fieldName, fieldText, MsgPhoneNotOK);
                else
                    {
                    fieldName.style.borderColor = "";
                    return ''
                    }
				break;
			default:
		        //Format does not exist
	        break;
		}
}


/****************************************************************/		
/*
Enter: The error message comming from strMsg is going to be show:  
        (int)showAlert = 1 will show a javascript message, 0 no
        (string)errorLabel = name of a label where is going to show the message. If empty or not a valid label will not show anything
        (string)strMsg = error message to be show
Exit: Boolean true if there are error and false if not.
*/
function ShowValidationMsgIfNeeded (showAlert,errorLabel)
{
    // Show validation messages if any
    // Show validation messages within an errorLabel and in a javascript message
    
    if (!(EmptyData(strMsg)))
	{
        //errorLabel message Format
        if ((document.getElementById(errorLabel)) != null){
        var warningLab = document.getElementById(errorLabel);
        //warningLab.innerHTML = ('<U>' + MsgWarningHead + '</U> '+ strMsg.replace(/#strReturn#/g,'<br />') + strMsgForExplanation.replace(/#strReturn#/g,'<br />'));
        warningLab.innerHTML = ('<U><B>' + MsgWarningHead + '</B></U><UL style="margin-bottom: 0px;margin-top: 0px;"> '+ strMsg.replace(/#strReturn#/g,'') + strMsgForExplanation.replace(/#strReturn#/g,'') + '</UL>');

        warningLab.style.display = 'inline';}
        
        var tempjsMsg1 = strMsg.replace(/\//g,'#@').replace(/#strReturn#/g,'\n').replace(eval('/'+strInitField.replace('/','#@')+'/g'),'').replace(eval('/'+strEndField.replace('/','#@')+'/g'),'').replace(eval('/'+strInitLine.replace('/','#@')+'/g'),'').replace(eval('/'+strEndLine.replace('/','#@')+'/g'),'');
        var tempjsMsg2 = strMsgForExplanation.replace(/\//g,'#@').replace(/#strReturn#/g,'\n').replace(eval('/'+strInitField.replace('/','#@')+'/g'),'').replace(eval('/'+strEndField.replace('/','#@')+'/g'),'').replace(eval('/'+strInitLine.replace('/','#@')+'/g'),'').replace(eval('/'+strEndLine.replace('/','#@')+'/g'),'');
        //Javascript message Format
       if (showAlert == 1){alert(MsgWarningHead + tempjsMsg1 + tempjsMsg2);}
	
	   ShowStylesInFields();	
	   strMsgForExplanation = '';
	return true;}else{return false;	}
}    


/****************************************************************/		
/*
Enter: 
Exit: 
*/
var FieldsToChangeStyles = '';//Store # separate values for all field with error values

function ShowStylesInFields(){
    //Format the style for ALL FIELDS
    var ArrayFieldsToChangeStyles = FieldsToChangeStyles.split('#');
    var i;
    for(i=0; i<ArrayFieldsToChangeStyles.length; i++){
        if ((document.getElementById(ArrayFieldsToChangeStyles[i])) != null){
        document.getElementById(ArrayFieldsToChangeStyles[i]).style.borderColor = "Red";
        }
	}
}

/****************************************************************/		
/*
Enter: 
Exit: 
*/
var strMsg; //store the message to be show in the browser 

function FormatValMessage(fieldName,fieldText, MessageToAdd){
    //Format the validation message for ALL FIELDS
    var tempstrMsg='';
    if (typeof(fieldName.name) == 'undefined'){
	    FieldsToChangeStyles += fieldName.id + '#';
    }else{
	    FieldsToChangeStyles += fieldName.name + '#';
	}
	//fieldName.style.borderColor = "Red";
	if (fieldText.toString().length > 0)
	    tempstrMsg = '#strReturn#' + strInitLine + strIndent + strInitField + fieldText + strEndField +  MessageToAdd + strEndLine ;
	    else //Without name of the field because is in the message. Useful in ValidateCustomFunction
	    tempstrMsg = '#strReturn#' + strInitLine + strIndent + MessageToAdd + strEndLine  ;
	
	strMsg += tempstrMsg;
    return tempstrMsg  ;
}

/****************************************************************/		
/*
Enter: 
Exit: 
*/
var strMsgForExplanation=''; //store the message to be show in the browser 

function FormatValMessageForExplanation(fieldName,fieldText, MessageToAdd){
    //Add Validation message for explanation if errors
    //Value is added to FormatValMessage if this is show
    //No field is formated
    var tempstrMsg='';
	if (fieldText.toString().length > 0)
	    tempstrMsg = '#strReturn#' + strInitLine + strIndent + strInitField + fieldText + strEndField + ' ' + MessageToAdd + strEndLine  ;
	    else //Without name of the field because is in the message. Useful in ValidateCustomFunction
	    tempstrMsg = '#strReturn#' + strInitLine + strIndent + ' ' + MessageToAdd + strEndLine  ;
	
	strMsgForExplanation += tempstrMsg;
    return tempstrMsg  ;
}


/****************************************************************/		
/*
	Enter: 
	Exit: 
*/
function checkEMAIL(EmailField){
    //check whether or not it is valid email
    correctEMAIL(EmailField);
    var vEmail = EmailField.value;
    var Byte="";
    var At=0;
    var Dot=0;
    for (var i=0;i<vEmail.length;i++)
    {
      Byte=vEmail.substring(i,i+1);
      if(Byte=="@")
        At=At+1;
      if (Byte==".")
        Dot=Dot+1;  
    }
    if (At==0)
    {
    return false;
    }else
        {
            if (Dot==0)
            {
                return(false);
            }else {
            return(true );
            }
         }
}
/****************************************************************/		
/*
	Enter: 
	Exit: 
*/
function correctEMAIL(fieldName) {
    //update email fields removing leading, trailing and interior spaces       
    var varFieldtext = document.getElementById(fieldName.name).value;
    var varFieldtextCorrected = TrimInteriorSpaces(varFieldtext);

    if (varFieldtext != varFieldtextCorrected){
        document.getElementById(fieldName.name).value = varFieldtextCorrected; 
        FormatValMessageForExplanation (fieldName, varFieldtext,  MsgHasBeenChangeTo  + ' ' + strInitField + varFieldtextCorrected + strEndField);
    }
}

/****************************************************************/		
/*
	Enter: 
	Exit: 
*/
function checkURL(vURL) {
    //check whether or not it is valid HTTP, HTTPS or FTP
    correctHttp(vURL);


    var RegexUrl = /(ftp|http|https|FTP|HTTP|HTTPS):\/\/(\w+:{0,1}\w*@)?(\S+)(:[0-9]+)?(\/|\/([\w#!:.?+=&%@!\-\/]))?/
    //var RegexUrl = (((https?)|(ftp)):\/\/([\-\w]+\.)+\w{2,3}(\/[%\-\w]+(\.\w{2,})?)*(([\w\-\.\?\\/+@&#;`~=%!]*)(\.\w{2,})?)*\/?)/i;
    if (vURL.value.indexOf('.')!=-1){
        return RegexUrl.test(vURL.value);
        }else{return false;}
    }
/****************************************************************/		
/*
	Enter: 
	Exit: 
*/
function correctHttp(fieldName) {
    //add http by default to URL fields and remove spaces
    var RegexHTTP = /(ftp|http|https|FTP|HTTP|HTTPS):\/\/?/
    var varFieldtext = document.getElementById(fieldName.name).value;
    var varFieldtextCorrected = TrimInteriorSpaces(varFieldtext);
    var strVarToAdd = '';
    
    if(!(RegexHTTP.test(varFieldtextCorrected))){
        if (fieldName.name.toLowerCase( ).indexOf('ftp')>=0){strVarToAdd = 'ftp://';}
        else if (fieldName.name.toLowerCase( ).indexOf('https')>=0){strVarToAdd = 'https://';}
        else{strVarToAdd = 'http://';}
    }
    
    if ((varFieldtext != varFieldtextCorrected) || (strVarToAdd !='')){
        document.getElementById(fieldName.name).value = strVarToAdd + varFieldtextCorrected; 
        FormatValMessageForExplanation (fieldName, varFieldtext,  MsgHasBeenChangeTo  + ' ' + strInitField + strVarToAdd + varFieldtextCorrected + strEndField);
    }
}

/****************************************************************/		
/*
	Enter: 
	Exit: 
*/

/*
^(\+[1-9][0-9]*(\([0-9]*\)|-[0-9]*-))?[0]?[1-9][0-9\- ]*$
- optional country code followed by area code surrounded with '-' or '(' and ')', 
or just an area code optionally starting with 0, followed by phone number. 
The number itself may contain spaces and '-'
Matches +123(45)678-910 | +123-045-67 89 10 | 01-234-56-78 
Non-Matches 123(45)678 91011 | (12)345-678 | +0(12)345-6789 

^[+][0-9]\d{2}-\d{3}-\d{4}$
Description This is a basic telephone number vaildation which needs a compulsory prefix of a '+' sign with three digits and followed by a hipen, another three digits and finally followed by another hipen and four more digits. Regards, Senthil Gunabalan 
Matches +974-584-5656 | +000-000-0000 | +323-343-3453 
Non-Matches 974-584-5656 | +974 000 0000 

*/

function checkPhone(vPhone){
    /* International phone number check 
    Validates on the following standards: +CCC.ZZZZZZZZZZxYYYY, where 
    'C' is the numeric country phone code (up to three digits), 
    'Z' is the phone number (up to 12 digits) and 
    'Y' is the extension (up to 4 digits); 
    max length overall is 20 characters, including the '+', '.', and 'x' (if extension is present). 
    Matches +800.4453377x4444 | +80.4453377 | +8.123456789123x1111 
    Non-Matches 181823884499 | +800.4453377x | 2486994x11 
    */
    correctPhone(vPhone);
    var RegexPhone = /^([\+][0-9]{1,3}[\.][0-9]{1,12})([x]?[0-9]{1,4}?)$/
    return RegexPhone.test(vPhone.value);
    }

/****************************************************************/		
/*
	Enter: 
	Exit: 
*/
function correctPhone(fieldName) {
    //update phone fields removing leading, trailing and interior spaces       
    var varFieldtext = document.getElementById(fieldName.name).value;
    var varFieldtextCorrected = TrimInteriorSpaces(varFieldtext).replace(/[\(]|[\)]|[-]/g,'');

    if (varFieldtext != varFieldtextCorrected){
        document.getElementById(fieldName.name).value = varFieldtextCorrected; 
        FormatValMessageForExplanation (fieldName, varFieldtext,  MsgHasBeenChangeTo  + ' ' + strInitField + varFieldtextCorrected + strEndField);
    }
}
/****************************************************************/		
/*
	Enter: 
	Exit: 
*/
function TrimInteriorSpaces(value) {
   var temp = value;
   var obj = /^(\s*)([\W\w]*)(\b\s*$)/;
   if (obj.test(temp)) { temp = temp.replace(obj, '$2'); }
   var obj = / /g;
   while (temp.match(obj)) { temp = temp.replace(obj, ""); }
   return temp;
}
/****************************************************************/		

/*
	Enter: 
	Exit: 
*/
function EmptyData(data){
	   //Boolean true/false if is an empty field
		if ((data == null) || (data == "") || (data == " ") )
		{
			return true;
		}
		return false;
	}

/****************************************************************/		
/*
	Enter: 
	Exit: 
*/
function checkNumeric(strString){
   //  check for valid numeric strings	
   var strValidChars = "0123456789.";
   var strChar;
   var blnResult = true;

   if (strString.length == 0) return true;
 
   for (i = 0; i < strString.length && blnResult == true; i++)
      {
      strChar = strString.charAt(i);
      if (strValidChars.indexOf(strChar) == -1)
         {
         blnResult = false;
         }
      }
   return blnResult;
   }

/****************************************************************/		
/*
	Enter: 
	Exit: 
*/
function HideMsgLabel(msgLabel) {
    //Hide messages label not needed
    if ((document.getElementById(msgLabel)) != null){
        document.getElementById(msgLabel).style.visibility='hidden'; } 
}

/****************************************************************/		
/*
	Enter: 
	Exit: 
*/
function FormatMandatoryField(fieldName) {
    //Add an background image to mandatory fields
    var Field = document.getElementById(fieldName);
    if ((Field) != null){
        switch (Field.type) {
			case 'select-one': 
			    //It is not working
                if (Field.value == '-1'){
                    Field.options[Field.selectedIndex].style.backgroundImage="url('../Images/MandatoryExclamation.gif')";
                    //Field.options[Field.selectedIndex].style.background="red";
                    //MandatoryExclamation.gif //MandatoryStart.gif //bg_red.gif //WF_Wrong.jpg
                }else{
                    Field.options[Field.selectedIndex].style.backgroundImage="url()"; 
                }
                Field.options[Field.selectedIndex].style.backgroundRepeat="no-repeat"; 
                Field.options[Field.selectedIndex].style.backgroundPosition="80% 0%";
				break;
			case 'select-multiple': 
                if (Field.options.length >0){
                    Field.style.backgroundImage="url()"; 
                }else{
                    Field.style.backgroundImage="url(../Images/MandatoryExclamation.gif)";
                }
                Field.style.backgroundRepeat="no-repeat"; 
                Field.style.backgroundPosition="right 100%";
				break;
			default:
                if ((Field.value.length) > 0){
                    Field.style.backgroundImage="url()"; 
                }else{
                    Field.style.backgroundImage="url(../Images/MandatoryExclamation.gif)";
                    //MandatoryExclamation.gif //MandatoryStart.gif //bg_red.gif //WF_Wrong.jpg
                }
                Field.style.backgroundRepeat="no-repeat"; 
                Field.style.backgroundPosition="right 100%";
	        break;
		}

    
    } 
}
/****************************************************************/		
/*
	Enter: 
	Exit: 
*/
function UnFormatMandatoryField(fieldName) {
    //Remove image from fields
    if ((document.getElementById(fieldName)) != null){
        document.getElementById(fieldName).style.backgroundImage="url()"; 
    } 
}
/****************************************************************/		
/*
	Enter: 
	Exit: 
*/
function VerifyRecursivelyMandatoryFields(){
    //It is called it itself recursively to all mandatory fields
    //onload="FormatMandatoriesField()" //alternative way to do it
    FormatMandatoriesField()
	setTimeout ('VerifyRecursivelyMandatoryFields()',1500);
}

function VerifyRecursivelyMandatoryFieldsFnc(functionNameToCall){
    //functionNameToCall is the FormatMandatoriesField unique for every form
    //It is called it itself recursively to all mandatory fields
    //onload="FormatMandatoriesField()" //alternative way to do it
    eval(functionNameToCall);
    //FormatMandatoriesField()
	setTimeout ('VerifyRecursivelyMandatoryFieldsFnc("' + functionNameToCall + '")',2100);
}


-->




