﻿function check_form(){

	var fname = document.getElementById("fname");
	var lname = document.getElementById("lname");
	var phone = document.getElementById("phone");
	var email = document.getElementById("email");
	
	if(fname.value == ""){
		alert("אנא הכנס שם פרטי תקני, תודה");
		fname.focus();
	}
	else if(lname.value == ""){
		alert("אנא הכנס שם משפחה תקני, תודה");
		lname.focus();
	}
	else if(phone.value == "" || isNaN(phone.value)){
		alert("אנא הכנס מספר טלפון תקני, תודה.");
		phone.focus();
	}
	else if(email.value != "" && !isValidEmail(email.value)){
		alert("אנא הכנס אימייל תקני, תודה");
		email.focus();
	}else{
		return true;
	}
	
	return false;
	
}

function isValidEmail(str) {

   return (str.indexOf(".") > 2) && (str.indexOf("@") > 0);

}