A lightweight Javascript Library for automatic direction change of input between rtl and ltr based on character count.
HTML5 dir="auto" attribution is good, but it just depends on first character in most browsers ,that is not functional on most arabic and persian web applications.
Include automatic-direction.js in bottom of the page before body close tag
<script src="js/automatic-direction.js"></script>
add .dir-auto class to input that you want to automate direction on it
<textarea class="dir-auto" ></textarea>
The code and the documentation are released under the MIT License
Thanks to @sallar for converting it to Vanilla js