I have this jQuery
code
$(window).load(function () {
$('document').ready(function () {
var text_max = "5000";
$('#ram').html(text_max + '/5000');
window.setInterval(function () {
$("#post").attr("maxlength", "5000");
var text_length = $('#post').val().length;
var text_remaining = text_max - text_length;
if ($("#post").val().length < 4750) {
$('#ram').html('<abbr title="You Have ' + text_remaining + ' Characters Remaining In This Post" style="visibility: hidden;">' + text_remaining + '/5000</abbr>');
} else {
$('#ram').html('<abbr title="You Have ' + text_remaining + ' Characters Remaining In This Post">' + text_remaining + '/5000</abbr>');
}
if ($("#post").val().length <= 5000) {
$("#subm").removeAttr("disabled");
} else {
$("#subm").attr("disabled", "disabled");
}
if ($("#post").val().length < 4980) {
$("#ram").removeAttr("style");
} else {
$("#ram").attr("style", "color:#ff0000;");
}
});
});
});
And My HTML
:
<form action='posting' method='POST'><center><font color='#ff0000' style='style=font-family: Sarala, sans-serif;display: inline-block;word-break: break-word;'></font><br><table><tr><td><textarea rows='15' cols='40' style='resize: none;max-width: 297px;max-height: 225px;width: 297px;height: 225px;' name='post' id='post' maxlength='5000' spellcheck='true' autofocus></textarea></center></td></tr><tr><td><div class='ram' id='ram' name='ram'><noscript><center>There Is A 500 Character Limit On All Posts</center></noscript></div></td></tr></table></td></tr><tr><td><center><input type='submit' value='Post!' class='subm' id='subm' name='subm'></center></td></tr></table></form>
However I want it to account the appropriate value of the textarea, however this is because when you press enter
it accounts it as 2
instead of 1
. What I need to do is to get the value to an equal amount opposed to an unequal amount. Is there any way of doing this, with the code below. Or would I completely need to redo it, if so I am not good at jQuery
or Javascript
; so I will need your help??
Thanks!!!