Created
January 25, 2012 07:48
-
-
Save farhadi/1675256 to your computer and use it in GitHub Desktop.
jQuery plugin to automatically set direction on input/textarea fields.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(function($) { | |
$.fn.autodir = function() { | |
return this.each(function() { | |
$(this).on('keypress keyup change', function() { | |
$(this).css('direction', $(this).val().match(/^[^a-z]*[^\x00-\x7E]/ig) ? 'rtl' : 'ltr'); | |
}).keyup(); | |
}); | |
}; | |
})(jQuery); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment