function isInputOk(formName,inputName,inputType,required)
{
	//version 1.0
	// trying to solve a part of the problem of repeating the code for validation
	// written by Bassel Ghazy on Monday, November 19, 2001 3:45:46 PM
	
	// formName: is the form that include the INPUT tag
	// inputName: is the id of the input
	// inputType: is the type that we want this input to be (text,number)
	// required: (true/false)
	
	// N.B: all input parameters to this function are string and case sensitve
	// here is an example: isInputOk('form1','password','text','true')
	
	if (inputType=="text")
	{
		ok=false;
		if ( required=='true' )
		{
			temp=eval("document."+formName+"."+inputName+".value");
			if ( (eval("document."+formName+"."+inputName+".value")=="") || (temp.indexOf(" ")==0) )
			{
				alert ("The "+inputName+ " field is required");
				eval("document."+formName+"."+inputName+".focus()");
				ok=false;
			}
			else
			{
				ok=true;		
			}
			
			return(ok);
		}
		else
		{
			temp=eval("document."+formName+"."+inputName+".value");
			if (temp.length==0)			
			{
				ok=true;			
			}
			else
			{
				ok=isInputOk(formName,inputName,inputType,'true');
			}

			return (ok);
		}
	}
	// case of number
	if ( inputType=="number" )
	{
		ok=false;
		if ( required=='true' )
		{
			temp=eval("document."+formName+"."+inputName+".value");
			if ( (eval("document."+formName+"."+inputName+".value")=="") || (temp.indexOf(" ")!=-1) )
			{
				alert ("The "+inputName+ " field is required");
				eval("document."+formName+"."+inputName+".focus()");
				ok=false;
			}
			else
			{
				ok=true;
			}
		}

		if ( isNaN(eval("document."+formName+"."+inputName+".value"))  || (eval("document."+formName+"."+inputName+".value")==""))
		{
			alert (inputName+" should be a number");
			eval("document."+formName+"."+inputName+".focus()");

			ok=false;
		}
		else
		{
			ok=true;
		}
		
		return(ok);
	}
	
}


function isInputOk2(formName,inputName,inputType,required,alertName)
{
	//version 1.1
	// trying to solve a part of the problem of repeating the code for validation
	// written by Bassel Ghazy on Wednesday, December 12, 2001 4:09:28 PM
	
	// formName: is the form that include the INPUT tag
	// inputName: is the id of the input
	// inputType: is the type that we want this input to be (text,number)
	// required: (true/false)
	//alertName: the Name of the control that will be in the ALERT
	
	// N.B: all input parameters to this function are string and case sensitve
	// here is an example: isInputOk2('form1','defVal','text','true','alert text')

	if (inputType=="text")
	{
		ok=false;
		if ( required=='true' )
		{
			temp=eval("document."+formName+"."+inputName+".value");
			if ( (eval("document."+formName+"."+inputName+".value")=="") || (temp.indexOf(" ")==0) )
			{
				alert ("The "+alertName+ " field is required");
				eval("document."+formName+"."+inputName+".focus()");
				ok=false;
			}
			else
			{
				ok=true;		
			}
			
			return(ok);
		}
		else
		{
			temp=eval("document."+formName+"."+inputName+".value");
			if (temp.length==0)			
			{
				ok=true;			
			}
			else
			{
				ok=isInputOk2(formName,inputName,inputType,'true',alertName);
			}

			return (ok);
		}
	}
	// case of number
	if ( inputType=="number" )
	{
		ok=false;
		if ( required=='true' )
		{
			temp=eval("document."+formName+"."+inputName+".value");
			if ( (eval("document."+formName+"."+inputName+".value")=="") || (temp.indexOf(" ")!=-1) )
			{
				alert ("The "+alertName+ " field is required");
				eval("document."+formName+"."+inputName+".focus()");
				ok=false;
			}
			else
			{
				ok=true;
			}
		}

		if ( isNaN(eval("document."+formName+"."+inputName+".value"))  || (eval("document."+formName+"."+inputName+".value")==""))
		{
			alert (alertName+" should be a number");
			eval("document."+formName+"."+inputName+".focus()");

			ok=false;
		}
		else
		{
			ok=true;
		}
		
		return(ok);
	}
	
}


function isInputOk3(formName,inputName,inputType,required,alertName)
{
	//version 1.2
	// trying to solve a part of the problem of repeating the code for validation
	// written by Bassel Ghazy on Wednesday, December 12, 2001 4:09:28 PM
	//version 1.2 solve the problem of single quote in the text
	
	// formName: is the form that include the INPUT tag
	// inputName: is the id of the input
	// inputType: is the type that we want this input to be (text,number)
	// required: (true/false)
	//alertName: the Name of the control that will be in the ALERT
	
	// N.B: all input parameters to this function are string and case sensitve
	// here is an example: isInputOk2('form1','defVal','text','true','alert text')

	if (inputType=="text")
	{
		ok=false;
		if ( required=='true' )
		{
			temp=eval("document."+formName+"."+inputName+".value");

			if ( (eval("document."+formName+"."+inputName+".value")=="") || (temp.indexOf(" ")==0) )
			{
				alert ("The "+alertName+ " field is required");
				eval("document."+formName+"."+inputName+".focus()");
				ok=false;
			}
			else
			{
				if (temp.indexOf("'")!=-1)
				{
					alert("Invalid "+alertName);
					ok=false;
				}
				else
				{
					ok=true;
				}
			}
			
			return(ok);
		}
		else
		{
			temp=eval("document."+formName+"."+inputName+".value");
			if (temp.length==0)			
			{
				ok=true;			
			}
			else
			{
				ok=isInputOk2(formName,inputName,inputType,'true',alertName);
			}

			return (ok);
		}
	}
	// case of number
	if ( inputType=="number" )
	{
		ok=false;
		if ( required=='true' )
		{
			temp=eval("document."+formName+"."+inputName+".value");
			if ( (eval("document."+formName+"."+inputName+".value")=="") || (temp.indexOf(" ")!=-1) )
			{
				alert ("The "+alertName+ " field is required");
				eval("document."+formName+"."+inputName+".focus()");
				ok=false;
			}
			else
			{
				ok=true;
			}
		}

		if ( isNaN(eval("document."+formName+"."+inputName+".value"))  || (eval("document."+formName+"."+inputName+".value")==""))
		{
			alert (alertName+" should be a number");
			eval("document."+formName+"."+inputName+".focus()");

			ok=false;
		}
		else
		{
			ok=true;
		}
		
		return(ok);
	}
	
}

function isInputOk4(formName,inputName,inputType,required,alertName)
{
	//version 1.3
	// trying to solve a part of the problem of repeating the code for validation
	// written by Bassel Ghazy on Wednesday, December 12, 2001 4:09:28 PM
	//version 1.3 solve the bug of the alerts with the numbers
	
	// formName: is the form that include the INPUT tag
	// inputName: is the id of the input
	// inputType: is the type that we want this input to be (text,number)
	// required: (true/false)
	//alertName: the Name of the control that will be in the ALERT
	
	// N.B: all input parameters to this function are string and case sensitve
	// here is an example: isInputOk4('form1','defVal','text','true','alert text')

	if (inputType=="text")
	{
		ok=false;
		if ( required=='true' )
		{
			temp=eval("document."+formName+"."+inputName+".value");

			if ( (eval("document."+formName+"."+inputName+".value")=="") || (temp.indexOf(" ")==0) )
			{
				alert ("The "+alertName+ " field is required");
				eval("document."+formName+"."+inputName+".focus()");
				ok=false;
			}
			else
			{
				if (temp.indexOf("'")!=-1)
				{
					alert("Invalid "+alertName);
					ok=false;
				}
				else
				{
					ok=true;
				}
			}
			
			return(ok);
		}
		else
		{
			temp=eval("document."+formName+"."+inputName+".value");
			if (temp.length==0)			
			{
				ok=true;			
			}
			else
			{
				ok=isInputOk2(formName,inputName,inputType,'true',alertName);
			}

			return (ok);
		}
	}
	// case of number
	if ( inputType=="number" )
	{
		ok=false;
		if ( required=='true' )
		{
			temp=eval("document."+formName+"."+inputName+".value");
			if ( (eval("document."+formName+"."+inputName+".value")=="") || (temp.indexOf(" ")!=-1) )
			{
				alert ("The "+alertName+ " field is required");
				eval("document."+formName+"."+inputName+".focus()");
				ok=false;
			}
			else
			{
				//ok
				if ( isNaN(eval("document."+formName+"."+inputName+".value")))
				{
					alert (alertName+" should be a number");
					eval("document."+formName+"."+inputName+".focus()");
		
					ok=false;
				}
				else
				{
					ok=true;
				}
				//ok
				
			}
		}
		else
		{
				if ( isNaN(eval("document."+formName+"."+inputName+".value"))  && (eval("document."+formName+"."+inputName+".value")!=""))
				{
					alert (alertName+" should be a number");
					eval("document."+formName+"."+inputName+".focus()");
		
					ok=false;
				}
				else
				{
					ok=true;
				}
		}
		
		return(ok);
	}
	
}