G
GarryJones
To show users how many characters they have left in a TEXTAREA input I
have been using "taCount" from a website I googled.
function taCount(visCnt) {
var taObj=event.srcElement;
if (taObj.value.length>taObj.maxLength*1)
taObj.value=taObj.value.substring(0,taObj.maxLength*1);
if (visCnt) visCnt.innerText=taObj.value.length;
}
After googling I found out that firefox does not allow
"event.srcElement" and "innerText" to work so I tried substituting
with
var taObj = (event.target) ? event.target : event.srcElement
innerText to innerHTML
But it is still not working.
Entire code..
<script language="JavaScript" type="text/javascript">
function taLimit(taObj) {
var taObj = (event.target) ? event.target : event.srcElement
if (taObj.value.length==taObj.maxLength*1) return false;
}
function taCount(taObj, visCnt) {
var taObj = (event.target) ? event.target : event.srcElement
if (taObj.value.length>taObj.maxLength*1)
taObj.value=taObj.value.substring(0,taObj.maxLength*1);
if (visCnt) visCnt.innerHTML=taObj.maxLength-taObj.value.length;
}
</script>
You have <B>
<div id="txtmsg" class="scfmfrm_dept"> </div>
<span id="myCounter">255</SPAN></B> characters remaining
for your description..
<TEXTAREA onkeypress="taLimit(this)" onkeyup="return taCount(this,
myCounter)"
name=Description rows=7 wrap=physical cols=40 maxLength="255"></
TEXTAREA>
Anyone know what other problems firefox is having with this?
Garry Jones
Sweden
have been using "taCount" from a website I googled.
function taCount(visCnt) {
var taObj=event.srcElement;
if (taObj.value.length>taObj.maxLength*1)
taObj.value=taObj.value.substring(0,taObj.maxLength*1);
if (visCnt) visCnt.innerText=taObj.value.length;
}
After googling I found out that firefox does not allow
"event.srcElement" and "innerText" to work so I tried substituting
with
var taObj = (event.target) ? event.target : event.srcElement
innerText to innerHTML
But it is still not working.
Entire code..
<script language="JavaScript" type="text/javascript">
function taLimit(taObj) {
var taObj = (event.target) ? event.target : event.srcElement
if (taObj.value.length==taObj.maxLength*1) return false;
}
function taCount(taObj, visCnt) {
var taObj = (event.target) ? event.target : event.srcElement
if (taObj.value.length>taObj.maxLength*1)
taObj.value=taObj.value.substring(0,taObj.maxLength*1);
if (visCnt) visCnt.innerHTML=taObj.maxLength-taObj.value.length;
}
</script>
You have <B>
<div id="txtmsg" class="scfmfrm_dept"> </div>
<span id="myCounter">255</SPAN></B> characters remaining
for your description..
<TEXTAREA onkeypress="taLimit(this)" onkeyup="return taCount(this,
myCounter)"
name=Description rows=7 wrap=physical cols=40 maxLength="255"></
TEXTAREA>
Anyone know what other problems firefox is having with this?
Garry Jones
Sweden