// Copyright © 2001 by Apple Computer, Inc., All Rights Reserved.
//
// You may incorporate this Apple sample code into your own code
// without restriction. This Apple sample code has been provided "AS IS"
// and the responsibility for its operation is yours. You may redistribute
// this code, but you are not permitted to redistribute it as
// "Apple sample code" after having made changes.

// email

function checkEmail (strng) {
var error="";
    var emailFilter=/^.+@.+\..{2,3}$/;
    if (!(emailFilter.test(strng))) { 
       error = "Indtast venligst en valid emailadresse.\n";
    }
    else {
//test email for illegale tegn
       var illegalChars= /[\(\)\<\>\,\;\:\\\"\[\]]/
         if (strng.match(illegalChars)) {
          error = "Emailadressen indeholder illegale tegn.\n";
       }
    }
return error;    
}

// Telefonnummer - fjern mellemrum og bindestreger, check for 8 cifre

function checkPhone (strng) {
var error = "";
if (strng == "") {
   error = "Du indtastede ikke et telefonnummer.\n";
}

var stripped = strng.replace(/[\(\)\.\-\ ]/g, ''); //strip out acceptable non-numeric characters
    if (isNaN(parseInt(stripped))) {
       error = "Telefonnumret indholder illegale tegn.";
  
    }
    if (!(stripped.length == 8)) {
	error = "Telefonnumret skal være præcis 8 cifre.\n";
    } 
return error;
}
// Kontrakt udfyldtfunction checkContract (strng) {var error = "";if (strng == "") {   error = "Du indtastede ikke et kontraktnummer.\n";}return error;}// Tællerstand farve udfyldtfunction checkCounterC (strng) {var error = "";if (strng == "") {   error = "Du indtastede ikke farve tællerstand.\n";}return error;}// Tællerstand sort/hvid udfyldtfunction checkCounterBW (strng) {var error = "";if (strng == "") {   error = "Du indtastede ikke sort/hvid tællerstand.\n";}return error;}// Tone faver udfyldtfunction checkAmount (strng) {var error = "";if (strng == "") {   error = "Du indtastede ikke antal toner.\n";}return error;}
// Navn udfyldt

function checkName (strng) {
var error = "";
if (strng == "") {
   error = "Du indtastede ikke et navn.\n";
}
return error;
}

// Firma udfyldt

function checkCompany (strng) {
var error = "";
if (strng == "") {
   error = "Du indtastede ikke et firma.\n";
}
return error;
}

// Forhandler valgt

function checkDropdown (choice) {
var error = "";
    if (choice == 0) {
    error = "Du valgte ikke en forhandler fra dropdown listen.\n";
    }    
return error;
}    

// Dato valgt

function checkDate (strng) {
	var error = "";
	myOption = -1;
	for (i=strng.length-1; i > -1; i--) {
		if (strng[i].checked) {
		myOption = i; i = -1;
		}
	}
	if (myOption == -1) {
    error = "Du valgte ikke hvilken dato.\n";
    }    
return error;
}