jQuery Plugin To Auto Set Text Direction In Text Fields - automatic-direction

File Size: 3.46 KB
Views Total: 1551
Last Update:
Publish Date:
Official Website: Go to website
License: MIT
   
jQuery Plugin To Auto Set Text Direction In Text Fields - automatic-direction

automatic-direction is a jQuery plugin which automatically set the text direction of your text field to Right To Left based on Character Count (If Arabic or Persian characters are more than Latin characters it will be RTL . ).

How to use it:

1. Insert the JavaScript file automatic-direction.js along with the latest jQuery library into the webpage.

<script src="//code.jquery.com/jquery.min.js"></script>
<script src="automatic-direction.js"></script>

2. Just add the CSS class 'dir-auto' to the textarea and/or input elements and the plugin will do the rest.

<textarea class="dir-auto"></textarea>
<input class="dir-auto">

3. The plugin also has the ability to Show the Arabic/Latin character count on front-end. Add the following HTML snippets to the webpage and we're done.

Arabic(or persian) characters: <span class="count-f"></span>
Latin Characters:  <span class="count-e"></span>
All Characters: <span class="count-all"></span>

Change log:

2016-12-23

  • Fixed: Count space as Latin characters

This awesome jQuery plugin is developed by miladd3. For more Advanced Usages, please check the demo page or visit the official website.