hi all , i want that user can not enter text in multiline textbox more than specific characters but it behaves differently in IE and FF. In Internet explorer when i press enter key it takes two character whereas in firefox when i press enter it takes only one character. so this way user can enter more data in FF which is not correct. how to fix that behavior so that both browsers give same result. My javascript code is given below
<HTML>
<HEAD>
<TITLE> Javascript Character Count by WebSewak.com </TITLE>
<script language=”Javascript”>
function counterUpdate(opt_countedTextBox, opt_countBody, opt_maxSize) {
var countedTextBox = opt_countedTextBox ? opt_countedTextBox : “counttxt”;
var countBody = opt_countBody ? opt_countBody : “countBody”;
var maxSize = opt_maxSize ? opt_maxSize : 1024;
var field = document.getElementById(countedTextBox);
if (field && field.value.length >= maxSize) {
field.value = field.value.substring(0, maxSize);
}
var txtField = document.getElementById(countBody);
if (txtField) {
txtField.innerHTML = field.value.length;
}
}
</script>
</HEAD>
<BODY>
<textarea id=”counttxt” name=”counttxt” rows=”10″ onkeyup=”counterUpdate(‘counttxt’, ‘countBody’,’30’);”></textarea>
You typed <B><span id=”countBody”>0</span></b> characters
Max. Length : 30 Chars
</BODY>
</HTML>