Figgifiggi: Regexp + Tabelle

Beitrag lesen

Bin neu in JavaScript finde den Fehler nicht, lg Figgi

<body>
<input id="street" type="text" placeholder="Straße Hausnummer PLZ Ort Land">
<button onclick="validate()">Test</button>
<table id="marks">

</body>
<script>
"use strict";

function tabelle() {
const MY_ROWS = document.getElementById("marks").getElementsByTagName("tr");
for (let k in MY_ROWS) {
if (k % 2 === 1 ) {
MY_ROWS [k].style.backgroundColor = "RED";
}
}
}
tabelle();

function validate()
{
const adresse = document.getElementById("street").value;
const regExp = /^[A-ZÄÖÜ][A-ZÄÖÜa-zäöüß-\s]* \d+[a-z]?(-\d+[a-z]?)? \d{5} [A-Z][A-ZÄÖÜa-zäöüß-\s]* [A-Z][A-ZÄÖÜa-zäöüß-\s]*$/;
let test = regExp.test(adresse);
if (test) {

document.getElementById("street").style.backgroundColor = "green";
document.getElementById("street").style.color = "white";
}
else {

document.getElementById("street").style.backgroundColor = "red";
document.getElementById("street").style.color = "white";
}
console.log(test);
}
</script>