function trim(inputString) { // Removes leading and trailing spaces from the passed string. Also removes // consecutive spaces and replaces it with one space. If something besides // a string is passed in (null, custom object, etc.) then return the input. if (typeof inputString != "string") { return inputString; } var retValue = inputString; var ch = retValue.substring(0, 1); while (ch == " ") { // Check for spaces at the beginning of the string retValue = retValue.substring(1, retValue.length); ch = retValue.substring(0, 1); } ch = retValue.substring(retValue.length-1, retValue.length); while (ch == " ") { // Check for spaces at the end of the string retValue = retValue.substring(0, retValue.length-1); ch = retValue.substring(retValue.length-1, retValue.length); } while (retValue.indexOf(" ") != -1) { // Note that there are two spaces in the string - look for multiple spaces within the string retValue = retValue.substring(0, retValue.indexOf(" ")) + retValue.substring(retValue.indexOf(" ")+1, retValue.length); // Again, there are two spaces in each of the strings } return retValue; // Return the trimmed string back to the user } // Ends the "trim" function function replace(inputString, fromString, toString) { // Goes through the inputString and replaces every occurrence of fromString with toString inputString = trim(inputString); fromString = trim(fromString); toString = trim(toString); var temp = inputString; if (fromString == "") { return temp; } if (toString.indexOf(fromString) == -1) { // If the string being replaced is not a part of the replacement string (normal situation) while (temp.indexOf(fromString) != -1) { var toTheLeft = temp.substring(0, temp.indexOf(fromString)); var toTheRight = temp.substring(temp.indexOf(fromString)+fromString.length, temp.length); temp = toTheLeft + toString + toTheRight; } } else { // String being replaced is part of replacement string (like "+" being replaced with "++") - prevent an infinite loop var midStrings = new Array("~", "`", "_", "^", "#"); var midStringLen = 1; var midString = ""; // Find a string that doesn't exist in the inputString to be used // as an "inbetween" string while (midString == "") { for (var i=0; i < midStrings.length; i++) { var tempMidString = ""; for (var j=0; j < midStringLen; j++) { tempMidString += midStrings[i]; } if (fromString.indexOf(tempMidString) == -1) { midString = tempMidString; i = midStrings.length + 1; } } } // Keep on going until we build an "inbetween" string that doesn't exist // Now go through and do two replaces - first, replace the "fromString" with the "inbetween" string while (temp.indexOf(fromString) != -1) { var toTheLeft = temp.substring(0, temp.indexOf(fromString)); var toTheRight = temp.substring(temp.indexOf(fromString)+fromString.length, temp.length); temp = toTheLeft + midString + toTheRight; } // Next, replace the "inbetween" string with the "toString" while (temp.indexOf(midString) != -1) { var toTheLeft = temp.substring(0, temp.indexOf(midString)); var toTheRight = temp.substring(temp.indexOf(midString)+midString.length, temp.length); temp = toTheLeft + toString + toTheRight; } } // Ends the check to see if the string being replaced is part of the replacement string or not return temp; // Send the updated string back to the user } // Ends the "replaceSubstring" function function isValidChar(str,par_invalidChars){ var invalidChars = " ~\'^\`\"*+=\\|][(){}$&!#%/:,;"; var ok = true; if (par_invalidChars != "") { invalidChars = par_invalidChars } for (i=0; i -1) { ok = false } } return ok; } function isEmail(email) { invalidChars = " ~\'^\`\"*+=\\|][(){}$&!#%/:,;"; email = emailStr = trim(email); // Check for null if (email == "") { return false; } // Check for invalid characters as defined above for (i=0; i -1) { return false; } } lengthOfEmail = email.length; if ((email.charAt(lengthOfEmail - 1) == ".") || (email.charAt(lengthOfEmail - 2) == ".")) { return false; } Pos = email.indexOf("@",1); if (email.charAt(Pos + 1) == ".") { return false; } while ((Pos < lengthOfEmail) && ( Pos != -1)) { Pos = email.indexOf(".",Pos); if (email.charAt(Pos + 1) == ".") { return false; } if (Pos != -1) { Pos++; } } // There must be at least one @ symbol atPos = email.indexOf("@",1); if (atPos == -1) { return false; } // But only ONE @ symbol if (email.indexOf("@",atPos+1) != -1) { return false; } // Also check for at least one period after the @ symbol periodPos = email.indexOf(".",atPos); if (periodPos == -1) { return false; } if (periodPos+3 > email.length) { return false; } return true; } function CheckVeld(Veld, Language) { var bOk = true; var Veldwaarde = Veld.value; var Veldnaam = Veld.id var Verplicht = Veldnaam.substring(Veldnaam.length - 2, Veldnaam.length -1) var Actie = Veldnaam.substring(Veldnaam.length - 1, Veldnaam.length) Veldnaam = Veldnaam.substring(0, Veldnaam.length - 2) var melding; var meldingleeg = "Veld mag niet leeg blijven"; var meldingnumeric = "Veld dient numerieke waarde te hebben"; var meldingemail = "Geen geldig emailadres"; var meldingalgemeen = "Geef geldige waarde voor '"; if (Language.toUpperCase() == 'EN') { meldingleeg = "Field should not be empty"; meldingnumeric = "Field should have a numeric value"; meldingemail = "No valid emailadress"; var meldingalgemeen = "Give valid value for '"; } //Check host url for localizing if((window.location.hostname.split("meinung")).length > 1) { meldingleeg = "Field should not be empty"; meldingnumeric = "Field should have a numeric value"; meldingemail = "No valid emailadress"; var meldingalgemeen = "Give valid value for '"; } if (Verplicht == 1 && Veldwaarde == "") { bOk = false; melding = meldingleeg; } else { switch (Actie) { case '1' : if (Number(Veldwaarde) != Veldwaarde) { bOk = false; melding = meldingnumeric; } break; case '2' : Veldwaarde = Veldwaarde.replace(/^\s*|\s*$/g,""); if((window.location.hostname.split("meinung")).length > 1) { regex= /^[a-zA-Z0-9_öäüß]+([-+.][a-zA-Z0-9_öäüß]+)*@[a-zA-Z0-9_öäüß]+([-.][a-zA-Z0-9_öäüß]+)*\.[a-zA-Z0-9_öäüß]+([-.][a-zA-Z0-9_öäüß]+)*$/; } else { regex=/^\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*$/; } //regex=/^.+\@(\[?)[a-zA-Z0-9\-\.]+\.([a-zA-Z]{2,3}|[0-9]{1,3})(\]?)$/; if (!regex.exec(Veldwaarde)) { bOk = false; melding = meldingemail; } break; case '3' : if((window.location.hostname.split("meinung")).length > 1) { regex=/^[öäüßa-zA-Z''-'\s]{1,255}$/; } else { regex=/^[a-zA-Z''-'\s]{1,255}$/; } if (!regex.exec(Veldwaarde)) { melding=""; bOk = false; } break; } } if (bOk == false) { alert (meldingalgemeen + Veldnaam + "'\n" + melding); try { Veld.focus() } catch(e) { //niets doen } finally { //niets doen } } return bOk; } function ValidateRadioButton(btnGroup, btnGroupName) { var cnt = -1; var bOk = false; for (var i=btnGroup.length-1; i > -1; i--) { if (btnGroup[i].checked) { cnt = i; i = -1; } } if (cnt > -1) { value = btnGroup[cnt].value; bOk = true; } if (bOk==false) { if((window.location.hostname.split("meinung")).length > 1) { alert("keine Option eingegeben für '" + btnGroupName + "'"); } else { alert("Geen optie ingevuld voor '" + btnGroupName + "'"); } } return bOk; } function CheckAndSubmit(language, form) { Disable(form.name,true); var bOk = true; var lengte = document.forms[form.name].elements.length for (var i = 0; i < lengte; i++) { var control = document.forms[form.name].elements[i] //snel even controle op radio ingebouwd - is lelijk if(control.type=="radio") { var radioGroup; eval("radioGroup=document."+form.name+"."+control.name); if (radioGroup!=null) { bOk = ValidateRadioButton(radioGroup, control.id); if (bOk==false) { i = lengte + 1; } } } else { if(!CheckVeld(control,language)) { bOk = false; i = lengte + 1; } } } if (bOk) { form.submit(); } else Disable(form.name,false); } function Disable(formname,bool) { try { document.forms[formname].elements["Submit"].disabled = bool; } catch(e) { //niets doen } finally { //niets doen } }