function validate(arg) { validated = true; var errormsg = ''; if(validated) { return true; } else { errormsg = "Følgende punkter er feil i skjemaet:\n\n" + errormsg; alert(errormsg); return false; } } function validate_color(arg,type) { var obj = document.getElementById(arg); switch(type) { case "tlf": if(obj.value.length > 7) { obj.style.border = "1px solid #7F9DB9"; } else { obj.style.border = "1px solid #ff0000"; } break; case "string": if(obj.value.length > 3) { obj.style.border = "1px solid #7F9DB9"; } else { obj.style.border = "1px solid #ff0000"; } break; case "email": if(obj.value.indexOf('@') != -1) { var splitter = obj.value.split('@'); if(splitter[1].indexOf('.') != -1) { obj.style.border = "1px solid #7F9DB9"; } else { obj.style.border = "1px solid #ff0000"; } } else { obj.style.border = "1px solid #ff0000"; } break; } }