Reverse text direction for HTML input
P粉217629009
P粉217629009 2023-08-22 12:58:49
0
2
662
<p>For my website, I need Arabic language support. Part of this is to provide an input text box where as the user types new characters must be appended to the left and the text must be right aligned. </p> <p>Set the CSS property to </p> <pre class="brush:php;toolbar:false;">text-align:right</pre> <p> didn't work because I couldn't move the cursor to the left and add letters there. So I removed that attribute and added </p> <pre class="brush:php;toolbar:false;">direction:RTL</pre> <p>Here, the cursor is moved to the left and the text is right-aligned. But the newly added characters are not appended to the left side, but only to the end of the right side. </p> <p>How do I fix this problem? Please help..</p> <p>For example, check out the search box on Google’s Arabic page. I need the exact same behavior, albeit without those fancy keyboard icons etc, http://www.google.com/webhp?hl=ar</p>
P粉217629009
P粉217629009

reply all(2)
P粉101708623

You can use dir="rtl" on the input box. It is supported.

<input dir="rtl" id="foo"/>
P粉982054449

This is what I can think of:

  • Use direction:RTL for right alignment
  • Write a JavaScript handler attached to the event "onkeyup" that moves the entered characters to the left (does some text processing).
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template