Try to fix textarea
This commit is contained in:
parent
a8fc530308
commit
fa372fdeb8
@ -1,3 +1,30 @@
|
|||||||
|
<style>
|
||||||
|
#comment {
|
||||||
|
resize: none;
|
||||||
|
overflow: hidden;
|
||||||
|
}
|
||||||
|
|
||||||
|
#comment-count {
|
||||||
|
right: 3px;
|
||||||
|
bottom: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
@supports selector(:has(html)) {
|
||||||
|
.was-validated .position-relative:has(:invalid)~.invalid-feedback {
|
||||||
|
display: block;
|
||||||
|
}
|
||||||
|
|
||||||
|
.was-validated :invalid~.invalid-feedback {
|
||||||
|
display: none !important;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@supports not selector(:has(html)) {
|
||||||
|
.was-validated :invalid~#comment-count {
|
||||||
|
display: none;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</style>
|
||||||
<form action="comment.php" method="post" class="needs-validation row m-0" novalidate>
|
<form action="comment.php" method="post" class="needs-validation row m-0" novalidate>
|
||||||
<div class="col">
|
<div class="col">
|
||||||
<h4 class="mb-3">Leave a Comment!</h4>
|
<h4 class="mb-3">Leave a Comment!</h4>
|
||||||
@ -15,8 +42,11 @@
|
|||||||
</div>
|
</div>
|
||||||
<div class="mb-3">
|
<div class="mb-3">
|
||||||
<div class="position-relative">
|
<div class="position-relative">
|
||||||
<textarea class="form-control" id="comment" name="comment" rows="3" maxlength="250" required placeholder="Comment here"></textarea>
|
<textarea class="form-control" id="comment" name="comment" maxlength="250" required placeholder="Comment here"></textarea>
|
||||||
<small class="text-muted position-absolute" id="comment-count" style="right: 20px; bottom: 0;">
|
<div class="invalid-feedback">
|
||||||
|
Please enter text.
|
||||||
|
</div>
|
||||||
|
<small class="text-muted position-absolute" id="comment-count">
|
||||||
0/250
|
0/250
|
||||||
</small>
|
</small>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@ -1,10 +1,10 @@
|
|||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
document.addEventListener("DOMContentLoaded", () => {
|
document.addEventListener("DOMContentLoaded", () => {
|
||||||
const handler = (event) => {
|
const handlerCounter = (event) => {
|
||||||
console.log(event.target);
|
const comment = event.target;
|
||||||
const length = event.target.value.length;
|
const length = comment.value.length;
|
||||||
const maxLength = event.target.maxLength;
|
const maxLength = comment.maxLength;
|
||||||
const counter = document.getElementById("comment-count");
|
const counter = document.getElementById("comment-count");
|
||||||
|
|
||||||
counter.innerText = `${length}/${maxLength}`;
|
counter.innerText = `${length}/${maxLength}`;
|
||||||
@ -18,10 +18,26 @@ document.addEventListener("DOMContentLoaded", () => {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
const addValidation = () => {
|
const handlerSize = () => {
|
||||||
const textarea = document.getElementById("comment");
|
const scroll = window.scrollY;
|
||||||
|
const comment = document.getElementById("comment");
|
||||||
|
const counter = document.getElementById("comment-count");
|
||||||
|
const commentHeight = comment.clientHeight;
|
||||||
|
const counterHeight = counter.clientHeight;
|
||||||
|
|
||||||
textarea.addEventListener("keyup", handler);
|
if (commentHeight + 0.5 * counterHeight < comment.scrollHeight) {
|
||||||
|
comment.style.height = `${comment.scrollHeight + counterHeight}px`;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
const addValidation = () => {
|
||||||
|
const comment = document.getElementById("comment");
|
||||||
|
const counter = document.getElementById("comment-count");
|
||||||
|
comment.style.height = `${comment.scrollHeight + counter.style.height}px`;
|
||||||
|
|
||||||
|
comment.addEventListener("input", handlerCounter);
|
||||||
|
comment.addEventListener("input", handlerSize);
|
||||||
|
window.addEventListener("resize", handlerSize);
|
||||||
};
|
};
|
||||||
|
|
||||||
addValidation();
|
addValidation();
|
||||||
|
|||||||
34
tasks/random/arrays.php
Normal file
34
tasks/random/arrays.php
Normal file
@ -0,0 +1,34 @@
|
|||||||
|
<?php
|
||||||
|
include_once "../../base/errors.php";
|
||||||
|
include_once "../../base/headers.php";
|
||||||
|
Headers::html();
|
||||||
|
|
||||||
|
$personen = array("Felix", "Berta", "Dalia", "Cecil", "Axel", "Elmar");
|
||||||
|
$toFind = "Cecil";
|
||||||
|
$zahlen = array(4, 7, 3, 10, 8, 1, 5);
|
||||||
|
|
||||||
|
foreach ($personen as $key => $name) {
|
||||||
|
if ($name === $toFind) {
|
||||||
|
echo "$name at $key";
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
?>
|
||||||
|
<br />
|
||||||
|
<?php
|
||||||
|
$max = 0;
|
||||||
|
$maxKey = 0;
|
||||||
|
foreach ($zahlen as $key => $value) {
|
||||||
|
if ($value > $max) {
|
||||||
|
$max = $value;
|
||||||
|
$maxKey = $key;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
echo "$max at $maxKey";
|
||||||
|
|
||||||
|
|
||||||
|
for ($i = 0; $i < 10; $i++) {
|
||||||
|
echo "$i<br/>";
|
||||||
|
}
|
||||||
|
echo "AFTER: $i<br/>";
|
||||||
Loading…
x
Reference in New Issue
Block a user