
//==============================================================================

function ValidateForm( fid ){

	var F;
	var N;
	var M;
	var T;
	var err;
	var e;
	var result;

	this.F = fid;
	this.err = false;
	this.e = 0;
	this.result = "";

	//-------------------------

	this.GetByID = function(ID){
		if(document.getElementById){
			return document.getElementById(ID);
		}else if(document.all){
	    return document.all[ID];
		}
	};

	this.chkNom = function(){
		this.N = GetByID(this.F).nom.value;
		this.err = false;
		if(this.N.length>=5){
			this.err = regNom();
		}else{
			this.err = true;
		}
		return( !this.err );
	};

	this.chkEmail = function(){
		this.M = GetByID(this.F).email.value;
		if(this.M.length>8){
			this.err = !regEmail();
		}else{
			this.err = true;
		}
		return( !this.err );
	};

	this.chkTel = function(){
		this.T = GetByID(this.F).tel.value;
		if(this.T.length>8){
			this.err = !regTel();
		}else{
			this.err = true;
		}
		return( !this.err );
	};

	//-------------------------

	this.regNom = function(){
		return(this.N.search(/^\w+((-\w+)|(\.\w+))*[0-9]+$/)!=-1);
	};

	this.regEmail = function(){
		return(this.M.search(/^\w+((-\w+)|(\.\w+))*\@[A-Za-z0-9]+((\.|-)[A-Za-z0-9]+)*\.[A-Za-z]+$/)!=-1);
	};

	this.regTel = function(){
		return(this.T.search(/^\w+((-\w+)|(\.\w+))*[0-9]+$/)!=-1);
	};

	//-------------------------

	if( !chkNom() ){this.e++;}
	if( !chkEmail() ){this.e++;}
	if( !chkTel() ){this.e++;}

	if( !this.e ){
		this.result = GetByID(this.F).submit();
	}else{
		this.result = alert("veuillez verifier votre saisi.");
	}

	//-------------------------

	return this.result;

	//-------------------------
}

//==============================================================================

function chkForm( fid ){
	chkRes = ValidateForm( fid );
	eval( chkRes );
}

//==============================================================================
