function MK_validateGoldLetter() { var missing = ''; if (!(document.getElementById('GL_Name')) || ((document.getElementById('GL_Name')).value == '')) { missing += "Ditt namn\n" } if (!document.getElementById('GL_PersonId') || (document.getElementById('GL_PersonId').value == '')) { missing += "Ditt personnummer\n" } if (!document.getElementById('GL_Address') || (document.getElementById('GL_Address').value == '')) { missing += "Din adress\n" } if (!document.getElementById('GL_Telephone') || !document.getElementById('GL_Email') || ((document.getElementById('GL_Telephone').value == '') && (document.getElementById('GL_Email').value == ''))) { missing += "Ditt telefonnummer eller e-postadress\n" } if (missing != '') { alert("Du har inte fyllt i alla nödvändiga fält i formuläret. Vi behöver:\n" + missing) return false; } if (valideraPersonnummer(document.getElementById('GL_PersonId').value) == false) { alert("Personnumret är inte korrekt ifyllt!") return false; } if (!((document.getElementById('GL_Email').value) == '') && (valideraEpost(document.getElementById('GL_Email').value) == false)) { alert("Epostadressen är inte korrekt ifylld!") return false; } var containsGold = MK_containsGold(); var containsOnlyGold = MK_containsOnlyGold(); if((containsGold) && !(containsOnlyGold)) { var response = confirm("OBS! Guldförsändelse® får endast innehålla föremål av guld. Om du har andra föremål, t.ex. silver, går det utmärkt att sända detta till oss som postpaket eller liknande. Vill du ändå beställa en Guldförsändelse® för dina guldföremål enbart?"); } else if (!containsGold) { var response = confirm("Du har inte fyllt i vilka guldföremål du vill skicka in till oss!\nFör att försäkringen ska gälla måste du bifoga en lista med alla dina föremål. \nEn sån lista alstras om du fyllt i formuläret först.\nVill du fortsätta utan att skapa listan? (rekommenderas ej)"); } if (response == false) { return false; } if (document.getElementById('GL_JSValidated')) { document.getElementById('GL_JSValidated').value = 'OK'; } return true; } function MK_containsGold() { for (var coll in itemTotalsArray) { for (var id in itemTotalsArray[coll]) { if (!isNaN(itemTotalsArray[coll][id]) && itemTotalsArray[coll][id] > 0) { el = document.getElementById(id+'_IsGold'); if ((el) && el.value == 'true') { return true; } } } } return false; } function MK_containsOnlyGold() { for (var coll in itemTotalsArray) { for (var id in itemTotalsArray[coll]) { if (!isNaN(itemTotalsArray[coll][id]) && itemTotalsArray[coll][id] > 0) { el = document.getElementById(id+'_IsGold'); if ((el) && el.value == 'false') { return false; } } } } return true; }