diff --git a/resources/views/events/create.blade.php b/resources/views/events/create.blade.php index 0667101..0e86109 100644 --- a/resources/views/events/create.blade.php +++ b/resources/views/events/create.blade.php @@ -42,6 +42,7 @@ @error('short_description') {{ $errors->first('short_description') }} @enderror + 0/280 characters
@@ -265,6 +266,29 @@ function toggleRecurringOptions() { // Initialize custom file input bsCustomFileInput.init(); + + /* Character counter */ + function updateCharacterCount() { + const textarea = document.getElementById('short_description'); + const characterCount = document.getElementById('characterCount'); + const count = textarea.value.length; + + characterCount.textContent = `${count}/280 characters`; + + if (count > 280) { + characterCount.classList.remove('text-muted'); + characterCount.classList.add('text-danger'); + } else { + characterCount.classList.remove('text-danger'); + characterCount.classList.add('text-muted'); + } + } + + // Add event listener for 'input' event + document.getElementById('short_description').addEventListener('input', updateCharacterCount); + + // Initialize the character count on page load in case there's already text in the textarea + document.addEventListener('DOMContentLoaded', updateCharacterCount); }); @endsection \ No newline at end of file