﻿//// JScript File

function validateForm( validationGroup )
{
    // Do nothing if client validation is not active

	if (typeof(Page_Validators) == "undefined")  return;
	// Change the color of the label

	var errorControls = [];
	var errorControlIndex = 0;

	for (var i = 0; i < Page_Validators.length; i++)
	{
		ValidatorValidate(Page_Validators[i], validationGroup);
		
		if (HasError(errorControls, Page_Validators[i].controltovalidate))
		{
			//ne rien faire
		}
		else if (document.getElementById(Page_Validators[i].id).isvalid)
		{
			document.getElementById(Page_Validators[i].controltovalidate).className = document.getElementById(Page_Validators[i].controltovalidate).className.replace(" champErreur", "");
		}
		else
		{
			errorControls[errorControlIndex] = Page_Validators[i].controltovalidate;
			errorControlIndex++;
			document.getElementById(Page_Validators[i].controltovalidate).className = document.getElementById(Page_Validators[i].controltovalidate).className + " champErreur";
		}
	}
}

function onChangeValidation( element )
{
	// Do nothing if client validation is not active
	
	if (typeof(Page_Validators) == "undefined")  return;
	// Change the color of the label

	var errorControls = [];
	var errorControlIndex = 0;

	for (var i = 0; i < Page_Validators.length; i++)
	{
		if (Page_Validators[i].controltovalidate == element.id)
		{
			ValidatorValidate(Page_Validators[i]);
			
			if (HasError(errorControls, Page_Validators[i].controltovalidate))
			{
				//ne rien faire
			}
			else if (document.getElementById(Page_Validators[i].id).isvalid)
			{
				document.getElementById(Page_Validators[i].controltovalidate).className = document.getElementById(Page_Validators[i].controltovalidate).className.replace(" champErreur", "");
			}
			else
			{
				errorControls[errorControlIndex] = Page_Validators[i].controltovalidate;
				errorControlIndex++;
				document.getElementById(Page_Validators[i].controltovalidate).className = document.getElementById(Page_Validators[i].controltovalidate).className + " champErreur";
			}
		}
	}
}


function HasError(errorControls, controlId)
{
	for (var i = 0; i < errorControls.length; i++)
	{
		if (errorControls[i] == controlId)
		{
			return true;
		}
	}
	
	return false;
}
