Anzeige nicht ausgefüllte Pflichtfelder bei weiter oft nicht eindeutig.
This commit is contained in:
@@ -186,6 +186,7 @@ xl:grid-cols-3 xl:gap-x-8 xl:gap-y-8
|
|||||||
onlyUnique={true}
|
onlyUnique={true}
|
||||||
minlength={4}
|
minlength={4}
|
||||||
maxlength={4}
|
maxlength={4}
|
||||||
|
required={true}
|
||||||
onFocusIn={() => {
|
onFocusIn={() => {
|
||||||
addNotification({
|
addNotification({
|
||||||
message: "Info",
|
message: "Info",
|
||||||
@@ -249,6 +250,7 @@ xl:grid-cols-3 xl:gap-x-8 xl:gap-y-8
|
|||||||
minlength={4}
|
minlength={4}
|
||||||
maxlength={4}
|
maxlength={4}
|
||||||
onlyUnique={true}
|
onlyUnique={true}
|
||||||
|
required={true}
|
||||||
onFocusIn={() => {
|
onFocusIn={() => {
|
||||||
addNotification({
|
addNotification({
|
||||||
message: "Info",
|
message: "Info",
|
||||||
@@ -287,6 +289,7 @@ xl:grid-cols-3 xl:gap-x-8 xl:gap-y-8
|
|||||||
onlyUnique={true}
|
onlyUnique={true}
|
||||||
minlength={4}
|
minlength={4}
|
||||||
maxlength={4}
|
maxlength={4}
|
||||||
|
required={true}
|
||||||
onFocusIn={() => {
|
onFocusIn={() => {
|
||||||
addNotification({
|
addNotification({
|
||||||
message: "Info",
|
message: "Info",
|
||||||
|
|||||||
@@ -44,11 +44,14 @@
|
|||||||
// Wir holen uns die Daten aus dem Formular
|
// Wir holen uns die Daten aus dem Formular
|
||||||
const data = new FormData(form);
|
const data = new FormData(form);
|
||||||
// Und gleichen diese mit allen Feldern ab die "required" sind, damit stellen wir sicher, dass alles richtig ausgefüllt wurde.
|
// Und gleichen diese mit allen Feldern ab die "required" sind, damit stellen wir sicher, dass alles richtig ausgefüllt wurde.
|
||||||
(form.querySelectorAll("select[name][required],input[name][required]") as NodeListOf<HTMLInputElement | HTMLSelectElement>).forEach((element) => {
|
console.log(form.querySelectorAll("select[name][required], input[name][required]"));
|
||||||
|
|
||||||
|
(form.querySelectorAll("select[name][required], input[name][required]") as NodeListOf<HTMLInputElement | HTMLSelectElement>).forEach((element) => {
|
||||||
const value = data.get(element.getAttribute("name") as string)
|
const value = data.get(element.getAttribute("name") as string)
|
||||||
|
|
||||||
if (!value && element.required) {
|
if (!value && element.required) {
|
||||||
element.setCustomValidity("Eine Auswahl ist verpflichtend.")
|
element.setCustomValidity("Eine Auswahl ist verpflichtend.")
|
||||||
|
element.dataset["isinvalid"] = "true"
|
||||||
} else {
|
} else {
|
||||||
element.setCustomValidity("")
|
element.setCustomValidity("")
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -19,6 +19,7 @@
|
|||||||
export let onFocusIn: () => any = () => {};
|
export let onFocusIn: () => any = () => {};
|
||||||
export let onFocusOut: () => any = () => {};
|
export let onFocusOut: () => any = () => {};
|
||||||
export let className: string = "";
|
export let className: string = "";
|
||||||
|
export let required: boolean = false;
|
||||||
|
|
||||||
function addTag(tag: string) {
|
function addTag(tag: string) {
|
||||||
if ((onlyUnique && tags.indexOf(tag) > -1) || maxTags == tags.length) {
|
if ((onlyUnique && tags.indexOf(tag) > -1) || maxTags == tags.length) {
|
||||||
@@ -48,6 +49,8 @@
|
|||||||
tag = ""
|
tag = ""
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$: required = tags.length > 0 ? false : required;
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<div
|
<div
|
||||||
@@ -83,6 +86,7 @@
|
|||||||
class="input input-bordered h-10 px-2 py-1.5 {className}"
|
class="input input-bordered h-10 px-2 py-1.5 {className}"
|
||||||
{minlength}
|
{minlength}
|
||||||
{maxlength}
|
{maxlength}
|
||||||
|
{required}
|
||||||
disabled={disable}
|
disabled={disable}
|
||||||
readonly={readonly}
|
readonly={readonly}
|
||||||
autocomplete="off"
|
autocomplete="off"
|
||||||
|
|||||||
@@ -302,3 +302,8 @@ article {
|
|||||||
transform: rotate(360deg);
|
transform: rotate(360deg);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* FORM VALIDATION MESSAGE */
|
||||||
|
[data-isinvalid="true"] {
|
||||||
|
border: 2px solid red !important;
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user