Count textarea characters

$(“#textarea”).keyup(function(){ $(“#count”).text($(this).val().length); }); The above will do what you want. If you want to do a count down then change it to this: $(“#textarea”).keyup(function(){ $(“#count”).text(“Characters left: ” + (500 – $(this).val().length)); }); Alternatively, you can accomplish the same thing without jQuery using the following code. (Thanks @Niet) document.getElementById(‘textarea’).onkeyup = function () { document.getElementById(‘count’).innerHTML = “Characters … Read more

Format text in a ?

If you need to customize your textarea, reproduce its behavior using another element (like a DIV) with the contenteditable attribute. It’s more customizable, and a more modern approach, textarea is just for plain text content, not for rich content. <div id=”fake_textarea” contenteditable></div> The scrollbars can be reproduced with the CSS overflow property. You can use … Read more

Set maxlength in Html Textarea [duplicate]

Before HTML5, we have an easy but workable way: Firstly set an maxlength attribute in the textarea element: <textarea maxlength=”250″ name=””></textarea> Then use JavaScript to limit user input: $(function() { $(“textarea[maxlength]”).bind(‘input propertychange’, function() { var maxLength = $(this).attr(‘maxlength’); if ($(this).val().length > maxLength) { $(this).val($(this).val().substring(0, maxLength)); } }) }); Make sure the bind both “input” and … Read more

How to center a textarea using CSS?

The margins won’t affect the textarea because it is not a block level element, but you can make it display block if you like: textarea { display: block; margin-left: auto; margin-right: auto; } By default, textareas are display: inline, which is why you can put them side-by-side easily, and why the text-align: center answers work … Read more

Cursor position in a textarea (character index, not x/y coordinates)

Modified BojanG’s solution to work with jQuery. Tested in Chrome, FF, and IE. (function ($, undefined) { $.fn.getCursorPosition = function() { var el = $(this).get(0); var pos = 0; if(‘selectionStart’ in el) { pos = el.selectionStart; } else if(‘selection’ in document) { el.focus(); var Sel = document.selection.createRange(); var SelLength = document.selection.createRange().text.length; Sel.moveStart(‘character’, -el.value.length); pos = … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)