
function chekForm(form)
{
	val = true;
	msg ="";
	for(i=0; i < form.elements.length; i++)
	{
		e = form.elements[i];
		local_match = true;
		if (e.getAttribute("required") == "1")
		{
			if (e.value == "") {
   				local_match = false;
			}
		}
		if (e.getAttribute("mustEqualTo") != null) {
			att = e.getAttribute("mustEqualTo");
			ref = form.elements[att];
			if (ref.value != e.value) {
   				local_match = false;
			}
		}
		if (e.getAttribute("mustMatchEmail") != null)
		{
			reg = /^[a-z0-9._-]+@[a-z0-9.-]{2,}[.][a-z]{2,3}$/
   			if (reg.exec(e.value) == null) {
   				local_match = false;
   			}
   		}
   		if (local_match) e.style.background = "white";
   		else {
   			e.style.background = "red";
   				val=false;
   		};
   	}
	if (val == false) alert("Warning : complete all needed fields");
	return val;
}

