function validerPostnr(formnavn)
{
  var navn=(document[formnavn].postnr.value);
	if (navn == "")
	{
    alert ("Du skal indtaste Postnr");
    document[formnavn].postnr.focus();
  	return 1;
	}
	return 0
}

function validerBynavn(formnavn)
{
  var navn=(document[formnavn].bynavn.value);
	if (navn == "")
	{
    alert ("Du skal indtaste navnet på den by du bor i");
    document[formnavn].bynavn.focus();
  	return 1;
	}
	return 0
}

function validerNavn(formnavn, feltnavn)
{
  var navn=(document[formnavn][feltnavn].value);
	if (navn == "")
	{
    alert ("Du skal indtaste et navn");
    document[formnavn][feltnavn].focus();
  	return 1;
	}
	return 0
}
function validerNavn(formnavn)
{
  var navn=(document[formnavn].navn.value);
	if (navn == "")
	{
    alert ("Du skal indtaste dit navn");
    document[formnavn].navn.focus();
  	return 1;
	}
	return 0
}
function validerFeltUdfyldt(formnavn, feltnavn, fejltekst)
{
  var navn=(document[formnavn][feltnavn].value);
	if (navn == "")
	{
    alert (fejltekst);
    document[formnavn][feltnavn].focus();
  	return 1;
	}
	return 0
}
function validerAdresse(formnavn)
{
	adresse=(document[formnavn].adresse.value);
	if (adresse == "")
	{
    alert ("Du skal indtaste din adresse");
    document[formnavn].adresse.focus();
    return 1;
	}
	return 0;
}
function validerTelefon(formnavn)
{
	telefon=(document[formnavn].telefon.value);
	if (telefon == "")
	{
    alert ("Du skal indtaste dit telefonnummer");
    document[formnavn].telefon.focus();
    return 1;
	}
	return 0;
}
function validerEMail(formnavn)
{
  placering=0;
  tekst=(document[formnavn].email.value).toLowerCase();
  placering=tekst.indexOf("@");
  if(tekst == "")
  {
    alert ("Du skal indtaste én e-mail adresse");
    document[formnavn].email.focus();
    return 1;
  }
  else
  {
    tegn=tekst.indexOf(" ");
    if(tegn!=-1)
    {
      alert ("Der må ikke være mellemrum i e-mail adressen");
	    document[formnavn].email.focus();
      return 1;
    }
    else
    {
      if (tekst.indexOf("æ")!=-1 || tekst.indexOf("ø")!=-1 || tekst.indexOf("å")!=-1 ||
        tekst.indexOf("Æ")!=-1 || tekst.indexOf("Ø")!=-1 || tekst.indexOf("Å")!=-1 ||
        tekst.indexOf(";")!=-1 || tekst.indexOf(",")!=-1)
      {
        alert ("Der er ulovlige tegn i adressen. Må ikke indeholde: æ ø å Æ Ø Å , ;");
		    document[formnavn].email.focus();
        return 1;
      }
	    else
	    {
	      if (placering<1 || tekst.length<=(placering+1))
	      {
	        alert ("e-mail adressen er forkert - forsøg igen");
			    document[formnavn].email.focus();
	        return 1;
	      }
	    }
  	}
	}
	return 0;
}
function validerDato(formnavn, feltnavn)
{
	if (!isDate(document[formnavn][feltnavn].value, 0))
	{
		alert("Du skal indtaste din fødselsdato i formatet: dd-mm-åååå");
		document[formnavn][feltnavn].focus();
		return 1;
	}
	return 0;
}
/**********************************************************************/
/*Function name :isDigit(theDigit) */
/*Usage of this function :test for an digit */
/*Input parameter required:thedata=string for test whether is digit */
/*Return value :if is digit,return true */
/* else return false */
/**********************************************************************/
function isDigit(theDigit)
{
	var digitArray = new Array('0','1','2','3','4','5','6','7','8','9'),j;

	for (j = 0; j < digitArray.length; j++)
	{
		if (theDigit == digitArray[j])
		return true
	}
	return false

}
/*************************************************************************/
/*Function name :isPositiveInteger(theString) */
/*Usage of this function :test for an +ve integer */
/*Input parameter required:thedata=string for test whether is +ve integer*/
/*Return value :if is +ve integer,return true */
/* else return false */
/*function require :isDigit */
/*************************************************************************/
function isPositiveInteger(theString)
{
var theData = new String(theString)

if (!isDigit(theData.charAt(0)))
if (!(theData.charAt(0)== '+'))
return false

for (var i = 1; i < theData.length; i++)
if (!isDigit(theData.charAt(i)))
return false
return true
}
/**********************************************************************/
/*Function name :isDate(s,f) */
/*Usage of this function :To check s is a valid format */
/*Input parameter required:s=input string */
/* f=input string format */
/* =1,in mm/dd/yyyy format */
/* else in dd/mm/yyyy */
/*Return value :if is a valid date return 1 */
/* else return 0 */
/*Function required :isPositiveInteger() */
/**********************************************************************/
function isDate(s,f)
{
	var a1=s.split("/");
	var a2=s.split("-");
	var e=true;
	if ((a1.length!=3) && (a2.length!=3))
	{
		e=false;
	}
	else
	{
		if (a1.length==3)
		var na=a1;
		if (a2.length==3)
		var na=a2;
		if (isPositiveInteger(na[0]) && isPositiveInteger(na[1]) && isPositiveInteger(na[2]))
		{
			if (f==1)
			{
				var d=na[1],m=na[0];
			}
			else
			{
				var d=na[0],m=na[1];
			}
			var y=na[2];
			if (((e) && (y<1000)||y.length>4))
			e=false
			if (e)
			{
				var v = new Date;
				v.setDate(d); v.setMonth(m); v.setFullYear(yy);
			if (v.getMonth()!=m-1)
			{
				e=false;
			}
			}
		}
		else
		{
			e=false;
		}
	}
	return e;
}


