﻿var contactForm=jQuery("#formular");
//console.log(contactForm);
if (contactForm) {
	contactForm.bind('submit',function(){
		name=document.forms[0].Name.value;
		email=document.forms[0].Email.value;
		telefon=document.forms[0].Telefon.value;
		anfrage=document.forms[0].Anfrage.value;

		errortext="";
		if (name=="") errortext+="*) Name\n";
		if (email=="" && telefon=="") errortext+="*) E-Mail oder Telefon\n";
		if (anfrage=="") errortext+="*) Anfrage\n";
		
		if (telefon!="" && !hasDigit(telefon)) errortext+="*) gültige Telefonnummer";
		
		if (errortext=="") return true;

		alert("Bitte füllen Sie folgende Felder aus:\n\n"+errortext);
		return false;
	});
}

function hasDigit(number){
	var digit=false;
	
	for (var i=0; i<number.length; i++)
	{
		if (number.charAt(i)==parseInt(number.charAt(i))) digit=true;
	}
	return digit;
}
