bestellformular datenüberprüfung verbessert

pull/3/head
spagb0l 2023-05-04 20:07:28 +02:00
parent 2738d02c15
commit e135d8662a
3 changed files with 521 additions and 503 deletions

View File

@ -57,7 +57,7 @@
<h1 id="begrueßung_bestellung_abschließen">Bestellung abschließen</h1> <h1 id="begrueßung_bestellung_abschließen">Bestellung abschließen</h1>
<div id="fehlerbox">test</div>
<form name="Bestellformular" > <form name="Bestellformular" >
<table class="bestellung_tabelle"> <table class="bestellung_tabelle">
<tr> <tr>
@ -108,7 +108,6 @@
</table> </table>
</form> </form>
<p id="tabellenbeschreibung">Die Felder mit einem * (Sternchen) sind Pflichtfelder.</p> <p id="tabellenbeschreibung">Die Felder mit einem * (Sternchen) sind Pflichtfelder.</p>
<p id="gesamtkosten"><strong>Die Gesamtkosten (inkl. MwSt.)</br>belaufen sich auf: 5,30€</strong> <p id="gesamtkosten"><strong>Die Gesamtkosten (inkl. MwSt.)</br>belaufen sich auf: 5,30€</strong>
@ -127,7 +126,7 @@
<div class="button_abschließen_position"> <div class="button_abschließen_position">
<p><a class="button_abschließen" onclick="checkform()" href="bestellung_erfolgreich.html" >Kostenpflichtig bestellen</a></p> <p><a id="bestellbutton" class="button_abschließen" href="bestellung_erfolgreich.html" >Kostenpflichtig bestellen</a></p>
</div> </div>

View File

@ -1,36 +1,37 @@
/* DESKTOP Version T4Web 0.1 */
/* DESKTOP Version T4Web 0.1 */ /* NONE FROM MOBILE */
/* NONE FROM MOBILE */ .header_mobile {
display: none;
}
.header_mobile { .header_mobilelogo {
display:none; display: none;
} }
.header_mobilelogo {
display:none;
}
.navbar-mobile{
display:none;
}
/* ALL-FORMAT */ .navbar-mobile {
display: none;
}
* { /* ALL-FORMAT */
* {
box-sizing: border-box; box-sizing: border-box;
font-family: Helvetica, Arial, sans-serif; font-family: Helvetica, Arial, sans-serif;
} }
#hinweis { #hinweis {
color: red; color: red;
} }
/* BACKGROUND-IMAGE-FORMAT-DESKTOP */ /* BACKGROUND-IMAGE-FORMAT-DESKTOP */
html body.index .content::before, html body.index .content::before,
html body.datenschutz .content::before, html body.datenschutz .content::before,
html body.ueberuns .content::before, html body.ueberuns .content::before,
html body.kontakt .content::before, html body.kontakt .content::before,
html body.impressum .content::before { html body.impressum .content::before {
content: ""; content: "";
background-image: url('../pictures/gemuese_transparent.png'); background-image: url('../pictures/gemuese_transparent.png');
background-repeat: no-repeat; background-repeat: no-repeat;
@ -44,128 +45,128 @@
left: 0px; left: 0px;
opacity: 0.2; opacity: 0.2;
pointer-events: none; pointer-events: none;
} }
/* NAV-DESKTOP-FORMAT */ /* NAV-DESKTOP-FORMAT */
.navbar-desktop { .navbar-desktop {
background-color: #476B1C; background-color: #476B1C;
display: grid; display: grid;
grid-template-columns: repeat(var(--items), 1fr); grid-template-columns: repeat(var(--items), 1fr);
width: 100%; width: 100%;
} }
.navbar-desktop a { .navbar-desktop a {
text-align: center; text-align: center;
text-decoration: none; text-decoration: none;
color: white; color: white;
padding: 0.5em 0 0.5em 0; padding: 0.5em 0 0.5em 0;
} }
.navbar-desktop a:hover { .navbar-desktop a:hover {
color: #f4eb49; color: #f4eb49;
} }
/* BODY-FORMAT */ /* BODY-FORMAT */
body { body {
min-height: 100vh; min-height: 100vh;
padding: 0; padding: 0;
} }
body::-webkit-scrollbar { body::-webkit-scrollbar {
width: 10px width: 10px
} }
body::-webkit-scrollbar-track { body::-webkit-scrollbar-track {
background-color: white; background-color: white;
} }
body::-webkit-scrollbar-thumb { body::-webkit-scrollbar-thumb {
background: #476B1C; background: #476B1C;
} }
/* HEADER-FORMAT */ /* HEADER-FORMAT */
header { header {
background-color: #9BB558; background-color: #9BB558;
} }
.header_desktop > h1 { .header_desktop>h1 {
padding-top: 0.1em; padding-top: 0.1em;
padding-left: 7em; padding-left: 7em;
margin: 0; margin: 0;
font-size: 1.875em; font-size: 1.875em;
} }
.header_desktop > p { .header_desktop>p {
padding-left: 17.6em; padding-left: 17.6em;
margin-top: 0em; margin-top: 0em;
margin-bottom: 0.5em; margin-bottom: 0.5em;
font-size: 0.75em; font-size: 0.75em;
} }
.header_logo { .header_logo {
float: left; float: left;
margin-top: -18px; margin-top: -18px;
margin-bottom: -20px; margin-bottom: -20px;
margin-left: -20px; margin-left: -20px;
transform: scale(0.8); transform: scale(0.8);
} }
/* CONTENT-FORMAT */ /* CONTENT-FORMAT */
.content { .content {
position: relative; position: relative;
color: black; color: black;
} }
.content p { .content p {
margin-top: 0.1em; margin-top: 0.1em;
margin-bottom: 0.1em; margin-bottom: 0.1em;
} }
.content :not(h1, strong, a) { .content :not(h1, strong, a) {
margin-left: 3.5em; margin-left: 3.5em;
color: #606060; color: #606060;
} }
.content h1 { .content h1 {
text-align: center; text-align: center;
font-size: 1.875em; font-size: 1.875em;
font-weight: normal; font-weight: normal;
margin-top: 0; margin-top: 0;
} }
.content h2 { .content h2 {
font-size: 1em; font-size: 1em;
text-align: center; text-align: center;
} }
.content a { .content a {
margin-left: 0em; margin-left: 0em;
} }
/* PRODUKTE-FORMAT */ /* PRODUKTE-FORMAT */
#aktuelle_auswahl { #aktuelle_auswahl {
margin-left: 2.7em; margin-left: 2.7em;
margin-bottom: -0.5em; margin-bottom: -0.5em;
font-size: 1em; font-size: 1em;
} }
.beispiel_produkte img { .beispiel_produkte img {
border: #606060 1px solid; border: #606060 1px solid;
height: 160px; height: 160px;
width: 150px; width: 150px;
margin-top: 1em; margin-top: 1em;
margin-left: 2em; margin-left: 2em;
} }
.button_produkte { .button_produkte {
background-color: #476B1C; background-color: #476B1C;
color: #fff; color: #fff;
padding: 5px 20px; padding: 5px 20px;
@ -176,51 +177,51 @@
font-size: 1em; font-size: 1em;
cursor: pointer; cursor: pointer;
margin-left: -1em; margin-left: -1em;
} }
a:hover { a:hover {
color:#f4eb49; color: #f4eb49;
} }
/* FOOTER-FORMAT */ /* FOOTER-FORMAT */
#balken { #balken {
background-color: #9BB558; background-color: #9BB558;
height: 20px; height: 20px;
position: relative; position: relative;
left: 0; left: 0;
bottom: 0; bottom: 0;
width: 100%; width: 100%;
} }
/* BESTELLUNG-FORMAT */ /* BESTELLUNG-FORMAT */
input { input {
font-family: Arial, Helvetica, sans-serif; font-family: Arial, Helvetica, sans-serif;
color: #606060 color: #606060
} }
label { label {
font-weight: normal; font-weight: normal;
border: none; border: none;
} }
#anrede, #anrede,
#titel, #titel,
#vorname, #vorname,
#name, #name,
#straße, #straße,
#hausnummer, #hausnummer,
#plz, #plz,
#wohnort, #wohnort,
#email { #email {
border: none; border: none;
width: 600px; width: 600px;
} }
.bestellung_tabelle { .bestellung_tabelle {
font-family: Arial, Helvetica, sans-serif; font-family: Arial, Helvetica, sans-serif;
font-size: 0.8em; font-size: 0.8em;
color: #606060; color: #606060;
@ -229,62 +230,62 @@
margin-left: 50px; margin-left: 50px;
border: thin solid #606060; border: thin solid #606060;
border-collapse: collapse; border-collapse: collapse;
} }
.bestellung_tabelle th { .bestellung_tabelle th {
border: thin solid #606060; border: thin solid #606060;
} }
.bestellung_tabelle td { .bestellung_tabelle td {
border: thin solid #606060; border: thin solid #606060;
width: 600px; width: 600px;
} }
.bestellung_tabelle tr { .bestellung_tabelle tr {
height: 25px; height: 25px;
} }
.stern { .stern {
width: 30px; width: 30px;
text-align: center; text-align: center;
} }
.feld_vorn { .feld_vorn {
width: 115px; width: 115px;
} }
#tabellenbeschreibung { #tabellenbeschreibung {
font-size: 0.8em; font-size: 0.8em;
margin-top: 6px; margin-top: 6px;
margin-left: 60px; margin-left: 60px;
} }
#gesamtkosten { #gesamtkosten {
font-size: 1em; font-size: 1em;
color: black; color: black;
margin-top: 40px; margin-top: 40px;
margin-left: 50px; margin-left: 50px;
} }
.checkboxen { .checkboxen {
display: inline-block; display: inline-block;
font-size: 0.8em; font-size: 0.8em;
text-align: justify; text-align: justify;
} }
.checkbox_ausrichtung { .checkbox_ausrichtung {
margin-left: 50px; margin-left: 50px;
} }
#begrueßung_bestellung_abschließen { #begrueßung_bestellung_abschließen {
font-size: 2em; font-size: 2em;
font-family: Arial, Helvetica, sans-serif; font-family: Arial, Helvetica, sans-serif;
color: black; color: black;
text-align: center; text-align: center;
margin-top: 0.5px; margin-top: 0.5px;
} }
.button_abschließen { .button_abschließen {
background-color: #476B1C; background-color: #476B1C;
color: white; color: white;
padding: 3px 10px; padding: 3px 10px;
@ -296,42 +297,42 @@
margin: 4px 2px; margin: 4px 2px;
cursor: pointer; cursor: pointer;
font-weight: normal; font-weight: normal;
} }
.button_abschließen_position { .button_abschließen_position {
margin-left: 100px; margin-left: 100px;
} }
.produktueberschrift { .produktueberschrift {
text-align: center; text-align: center;
margin: 50px; margin: 50px;
} }
.parent { .parent {
display: flex; display: flex;
justify-content: space-around; justify-content: space-around;
flex-wrap: wrap; flex-wrap: wrap;
align-content: center; align-content: center;
} }
.produkte { .produkte {
display: flex; display: flex;
border: #606060 3px solid; border: #606060 3px solid;
display: inline-block; display: inline-block;
margin: 25px; margin: 25px;
} }
.produktbottom { .produktbottom {
justify-content: space-between; justify-content: space-between;
display: flex; display: flex;
margin: 10px; margin: 10px;
} }
.produktbottom a { .produktbottom a {
position: relative; position: relative;
} }
.produkte_warenkorb { .produkte_warenkorb {
position: relative; position: relative;
max-width: 88%; max-width: 88%;
height: 165px; height: 165px;
@ -340,33 +341,33 @@
margin-bottom: 22.5px; margin-bottom: 22.5px;
display: flex; display: flex;
align-items: center; align-items: center;
} }
.produkte_warenkorb img { .produkte_warenkorb img {
margin-right: 0px; margin-right: 0px;
height: 60%; height: 60%;
} }
.content .produkte_details { .content .produkte_details {
color: black; color: black;
font-weight: bold; font-weight: bold;
width: 150px; width: 150px;
display: block; display: block;
font-size: 0.8em; font-size: 0.8em;
margin-top: -40px; margin-top: -40px;
} }
.button_mit_menue { .button_mit_menue {
display: flex; display: flex;
align-items: center; align-items: center;
position: absolute; position: absolute;
bottom: 50px; bottom: 50px;
right: 30px; right: 30px;
} }
.button_entfernen { .button_entfernen {
background-color: #ebebeb; background-color: #ebebeb;
border: thin solid black; border: thin solid black;
color: black; color: black;
@ -382,31 +383,31 @@
cursor: pointer; cursor: pointer;
font-weight: normal; font-weight: normal;
} }
#menue { #menue {
width: 35px; width: 35px;
height: 25px; height: 25px;
margin-left: 10px; margin-left: 10px;
} }
.content .gesamtbetrag { .content .gesamtbetrag {
font-weight: bold; font-weight: bold;
color: black; color: black;
position: absolute; position: absolute;
font-size: 1em; font-size: 1em;
bottom: 15px; bottom: 15px;
right: 15px; right: 15px;
} }
.gesamtbetrag { .gesamtbetrag {
position: absolute; position: absolute;
font-size: 1em; font-size: 1em;
bottom: 15px; bottom: 15px;
right: 15px; right: 15px;
} }
.button_hinzufuegen { .button_hinzufuegen {
background-color: #9BB558; background-color: #9BB558;
color: white; color: white;
padding: 10px; padding: 10px;
@ -421,17 +422,17 @@
position: relative; position: relative;
box-shadow: 0px 4px 3px rgba(0, 0, 0, 0.3); box-shadow: 0px 4px 3px rgba(0, 0, 0, 0.3);
margin-top: 0.5em; margin-top: 0.5em;
} }
.button_hinzufuegen::before { .button_hinzufuegen::before {
content: "+"; content: "+";
position: absolute; position: absolute;
transform: translate(-50%, -40%); transform: translate(-50%, -40%);
font-size: 3em; font-size: 3em;
font-weight: normal; font-weight: normal;
} }
#notification { #notification {
display: none; display: none;
position: fixed; position: fixed;
top: 0; top: 0;
@ -442,9 +443,9 @@
text-align: center; text-align: center;
padding: 10px; padding: 10px;
z-index: 999; z-index: 999;
} }
.content .äußererContainer { .content .äußererContainer {
position: relative; position: relative;
bottom: 0; bottom: 0;
width: 400px; width: 400px;
@ -454,9 +455,9 @@
margin-bottom: 22.5px; margin-bottom: 22.5px;
display: grid; display: grid;
grid-template-rows: auto auto; grid-template-rows: auto auto;
} }
.content .kostenContainer { .content .kostenContainer {
position: relative; position: relative;
width: 300px; width: 300px;
@ -465,37 +466,37 @@
font-size: 0.9em; font-size: 0.9em;
display: inline-block; display: inline-block;
margin-left: 0px; margin-left: 0px;
} }
.content .lieferkosten_text { .content .lieferkosten_text {
color: black; color: black;
display: inline-block; display: inline-block;
margin-left: 0px; margin-left: 0px;
margin-right: 110px; margin-right: 110px;
text-align: right; text-align: right;
} }
.content .lieferkosten_preis { .content .lieferkosten_preis {
color: black; color: black;
display: inline-block; display: inline-block;
} }
.content .gesamtkosten_text{ .content .gesamtkosten_text {
color: black; color: black;
display: inline-block; display: inline-block;
text-align: left; text-align: left;
margin-left: 0; margin-left: 0;
margin-right: 63px; margin-right: 63px;
} }
.content .gesamtpreis{ .content .gesamtpreis {
color: black; color: black;
display: inline-block; display: inline-block;
margin-left: 0; margin-left: 0;
} }
.content .button_bestellung_abschließen { .content .button_bestellung_abschließen {
background-color: #476B1C; background-color: #476B1C;
color: white; color: white;
padding: 3px 10px; padding: 3px 10px;
@ -507,4 +508,10 @@
margin: 4px 2px; margin: 4px 2px;
cursor: pointer; cursor: pointer;
font-weight: normal; font-weight: normal;
} }
#fehlerbox {
text-align: center;
display: none;
color: red;
}

View File

@ -3,7 +3,7 @@ let x = Number(localStorage.getItem("gesamtpreis")).toFixed(2);
let y = document.getElementById("gesamtkosten"); let y = document.getElementById("gesamtkosten");
y.innerHTML = "Die Gesamtkosten (inkl. MwSt.) belaufen sich auf: " + x + "€"; y.innerHTML = "Die Gesamtkosten (inkl. MwSt.) belaufen sich auf: " + x + "€";
function checkform() { function checkform(event) {
let vorname = document.getElementById('vorname').value; let vorname = document.getElementById('vorname').value;
let name = document.getElementById('name').value; let name = document.getElementById('name').value;
let straße = document.getElementById('straße').value; let straße = document.getElementById('straße').value;
@ -12,11 +12,23 @@ function checkform() {
let wohnort = document.getElementById('wohnort').value; let wohnort = document.getElementById('wohnort').value;
let email = document.getElementById('email').value; let email = document.getElementById('email').value;
if (/[a-zA-Z]{2,}/.test(vorname) === false) alert('vorname falsch'); fehlerbox.innerHTML = 'Fehler: <br>';
if (/[a-zA-Z]{2,}/.test(name) === false) alert('name falsch');
if (/[a-zA-Z]{2,}/.test(straße) === false) alert('straße falsch'); if (/[a-zA-Z]{2,}/.test(vorname) === false) fehlerbox.innerHTML += 'Vorname: mindestens zwei Buchstaben <br>';
if (/[0-9]{1,}/.test(hausnummer) === false) alert('hausnummer falsch'); if (/[a-zA-Z]{2,}/.test(name) === false) fehlerbox.innerHTML += 'Name: mindestens zwei Buchstaben <br>';
if (/[0-9]{4,5}/.test(plz) === false) alert('plz falsch'); if (/[a-zA-Z0-9]{2,}/.test(straße) === false) fehlerbox.innerHTML += 'Straße: mindestens zwei Zeichen <br>';
if (/[a-zA-Z]{2,}/.test(wohnort) === false) alert('wohnort falsch'); if (/[0-9]{1,}/.test(hausnummer) === false) fehlerbox.innerHTML += 'Hausnummer: mindestens eine Zahl <br>';
if (/^([a-zA-Z0-9]+([-_\.]?[a-zA-Z0-9])+@[a-zA-Z0-9]+([-_\.]?[a-zA-Z0-9])+\.[a-z]{2,4}){0,}$/.test(email) === false) alert('email falsch'); if (/[0-9]{4,5}/.test(plz) === false) fehlerbox.innerHTML += 'Postleitzahl: mindestens vier Zahlen <br>';
if (/[a-zA-Z]{2,}/.test(wohnort) === false) fehlerbox.innerHTML += 'Wohnort: mindestens zwei Buchstaben <br>';
if (/^([a-zA-Z0-9]+([-_\.]?[a-zA-Z0-9])+@[a-zA-Z0-9]+([-_\.]?[a-zA-Z0-9])+\.[a-z]{2,4}){0,}$/.test(email) === false) fehlerbox.innerHTML += 'EMail: bitte nach dem Muster "email@beispiel.de" <br>';
if(fehlerbox.innerHTML.length > 12) {
event.preventDefault();
let fehlerboxstyle = document.getElementById('fehlerbox');
fehlerbox.style = 'display: block;'
}
} }
const fehlerbox = document.getElementById('fehlerbox');
const bestellbutton = document.getElementById('bestellbutton');
bestellbutton.addEventListener('click', checkform, false);