form method
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
2023-08-29 16:43:53 +02:00
parent 164e339870
commit 171f68747e
2 changed files with 28 additions and 5 deletions

21
app/public/js/form.js Normal file
View File

@ -0,0 +1,21 @@
(function() {
const form = document.getElementById('form');
const textarea = document.getElementById('str');
// Change the form method between GET and POST based on the textarea length
const updateFormMethod = () => {
const maxLength = 1024;
const textLength = textarea.value.length;
console.log(textLength);
if (textLength > maxLength) {
form.method = 'post';
} else {
form.method = 'get';
}
}
document.addEventListener('DOMContentLoaded', updateFormMethod);
textarea.addEventListener('input', updateFormMethod);
})();