// Global variables var isCSS, isW3C, isIE4, isNN4, isIE6CSS; // initialize upon load to let all browsers establish content objects function initDHTMLAPI( ) { if (document.images) { isCSS = (document.body && document.body.style) ? true : false; isW3C = (isCSS && document.getElementById) ? true : false; isIE4 = (isCSS && document.all) ? true : false; isNN4 = (document.layers) ? true : false; isIE6CSS = (document.compatMode && document.compatMode.indexOf("CSS1") >= 0) ? true : false; } } // set event handler to initialize API window.onload = initDHTMLAPI; function getObject(obj) { var theObj; if (typeof obj == "string") { if (isW3C) { theObj = document.getElementById(obj); } else if (isIE4) { theObj = document.all(obj); } else if (isNN4) { theObj = seekLayer(document, obj); } } else { // pass through object reference theObj = obj; } return theObj; } function CheckMin(Min, Max) { var MinNumber = getObject(Min); var MaxNumber = getObject(Max); if (onlyNumbers(MinNumber.value) && onlyNumbers(MaxNumber.value)) { if (!IsEmpty(MinNumber) && !IsEmpty(MaxNumber)) { if (Math.max(MinNumber.value,MaxNumber.value)==MinNumber.value) { alert("Mindestwert kann nicht gr\366\337er sein als der gegebene H\366chstwert " + MaxNumber.value + ". Bitte den Wert \344ndern."); MinNumber.value=""; MinNumber.focus(); } } } } function CheckMax(Min, Max) { var MinNumber = getObject(Min); var MaxNumber = getObject(Max); if (onlyNumbers(MaxNumber.value) && onlyNumbers(MinNumber.value)) { if (!IsEmpty(MinNumber) && !IsEmpty(MaxNumber)) { if (Math.min(MinNumber.value,MaxNumber.value)==MaxNumber.value) { alert("H\366chstwert kann nicht kleiner sein als der Mindestwert " + MinNumber.value + ". Bitte den Wert \344ndern."); MaxNumber.value=""; MaxNumber.focus(); // hier er maar weer wel op gedaan = focus want error als alleen focus zonder alert } } } } function IsEmpty(aTextField) { var Empty; Empty = ((aTextField.value.length == 0) || (aTextField.value==null)) ? true : false; return Empty; } function doNoPref (aTextField) { // voor IE toch de object pakken en aTextField is dus 'id' var aTextField = getObject(aTextField); if (!onlyNumbers(aTextField.value) || IsEmpty(aTextField)) { aTextField.value = "no pref"; // aTextField.focus(); } } function EmptyIfPref (aTextField) { // voor IE toch de object pakken en aTextField is dus 'id' var aTextField = getObject(aTextField); if (aTextField.value == "no pref") { aTextField.value=""; // aTextField.focus(); } } function onlyNumbers(inputString) { var amount_dots = 0; var amount_e = 0; var answer = true; var i; for (i=0 ; i < inputString.length ; i++) { if ((inputString.charCodeAt(i) < 45) || (inputString.charCodeAt(i) > 57) || (inputString.charCodeAt(i) ==47)) { if ((inputString.charCodeAt(i) == 69) || (inputString.charCodeAt(i) == 101)) { if (i==0) { answer = false; } else { amount_e = amount_e + 1; } } else { answer = false; } } if (inputString.charCodeAt(i) == 46) { amount_dots = amount_dots + 1; } } if (amount_dots > 1) { answer = false; } if (amount_e > 1) { answer = false; } return answer; } function IsLargerThan (ID, getal) { var CompareThis = getObject(ID); if (!IsEmpty(CompareThis)) { if (parseFloat(CompareThis.value) < parseFloat(getal)) { alert("Wert ist kleiner als " + getal + ". Bitte den Wert \344ndern."); CompareThis.value=""; CompareThis.focus(); } } } function IsSmallerThan (ID, getal) { var CompareThis = getObject(ID); if (!IsEmpty(CompareThis)) { if (parseFloat(getObject(ID).value) > parseFloat(getal)) { alert("Wert ist gr\366\337er als " + getal + ". Bitte den Wert \344ndern."); CompareThis.value=""; CompareThis.focus(); } } } function IsLargerOrEqualTo (ID, getal) { var CompareThis = getObject(ID); if (!IsEmpty(CompareThis)) { if (parseFloat(CompareThis.value) <= parseFloat(getal)) { alert("Wert ist kleiner als oder ebenso gro\337 wie " + getal + ". Bitte den Wert \344ndern."); CompareThis.value=""; CompareThis.focus(); } } } function IsSmallerOrEqualTo (ID, getal) { var CompareThis = getObject(ID); if (!IsEmpty(CompareThis)) { if (parseFloat(CompareThis.value) >= parseFloat(getal)) { alert("Wert ist gr\366\337er als oder ebenso gro\337 wie " + getal + ". Bitte den Wert \344ndern."); CompareThis.value=""; CompareThis.focus(); } } } function CheckNumber(ID) { var CheckThis = getObject(ID); if (!onlyNumbers (CheckThis.value)) { alert("Bitte Nummer eingeben."); CheckThis.value=""; CheckThis.focus(); } } function CheckStringLength (ID, maxlength) { var StringObject = getObject(ID); if (!(( StringObject.value==null) || ( StringObject.value.length <= maxlength))) { StringObject.value = StringObject.value.substring(0,maxlength); } }