javascript - How to Change CSS direction property of the input field automaticly if the user can use an language rtl or ltr -


example: if use arabic language text field direction rtl , if want write new text , switch english language direction inside text field (`text-align: left) ltr automatically

you use global html5 attribute dir value of auto here, so:

<input type="text" dir="auto" /> 

from specification:

the auto keyword, maps auto state indicates contents of element explicitly embedded text, direction determined programmatically using contents of element (as described below).

note: heuristic used state crude (it looks @ first character strong directionality, in manner analogous paragraph level determination in bidirectional algorithm). authors urged use value last resort when direction of text unknown , no better server-side heuristic can applied.

http://www.w3.org/tr/html5/elements.html#the-dir-attribute

as quote suggests, better find out on server side direction should used, can use if have no way of knowing it.


Comments

Popular posts from this blog

jQuery Ajax Render Fragments OR Whole Page -

javascript - Iterate over array and calculate average values of array-parts -

java - Simple Command Line calculator -