Forked from ahsannayem/Set Minimum characters for Text Area
Created
September 4, 2023 20:27
-
-
Save belalismail/00f98b3600f6d8e539d3cf28b5f8e50d to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const textarea = document.getElementById('TextArea_ID'); // Replace the id | |
textarea.addEventListener('input', function() { | |
const minTextLength = 10; // Set Minimum required text length | |
if (textarea.value.length < minTextLength) { | |
textarea.setCustomValidity('Please enter at least ' + minTextLength + ' characters.'); | |
} else { | |
textarea.setCustomValidity(''); | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment