JSFiddle - React, Tailwind, and code Playground
HTML
<input type="text" placeholder="What are you doing today?">
CSS
input
{
direction:rtl;
}
JavaScript
$('input').keyup(function(){
$this = $(this);
if($this.val().length == 1)
{
var x = new RegExp("[\x00-\x80]+"); // is ascii
//alert(x.test($this.val()));
var isAscii = x.test($this.val());
if(isAscii)
{
$this.css("direction", "ltr");
}
else
{
$this.css("direction", "rtl");
}
}
});