I have a textarea input field for the email message. How do i limit the number of characters in the field to, say 10000?
Michael
Michael
<script type="text/javascript">
setMaxLength;
</script>
function setMaxLength() {
var x = document.getElementsByTagName('textarea');
var counter = document.createElement('div');
counter.className = 'counter';
for (var i=0;i<x.length;i++) {
if (x[i].getAttribute('maxlength')) {
var counterClone = counter.cloneNode(true);
counterClone.relatedElement = x[i];
counterClone.innerHTML = '<span>0</span>/'+x[i].getAttribute('maxlength');
x[i].parentNode.insertBefore(counterClone,x[i].nextSibling);
x[i].relatedElement = counterClone.getElementsByTagName('span')[0];
x[i].onkeyup = x[i].onchange = checkMaxLength;
x[i].onkeyup();
}
}
}
function checkMaxLength() {
var maxLength = this.getAttribute('maxlength');
var currentLength = this.value.length;
if (currentLength > maxLength)
this.relatedElement.className = 'toomuch';
else
this.relatedElement.className = '';
this.relatedElement.firstChild.nodeValue = currentLength;
// not innerHTML
}
<textarea class="cf_inputbox required" maxlength="100" rows="10" id="message" cols="70" name="message"></textarea>
<script type="text/javascript">
setMaxLength();
</script>
this.disabled=true;
but that might be heavy handed and doesn't allow the user to edit. this.style.borderColor= 'red'
is another alternative!if ( md5($chrono_verification ) != $sessionvar ) {
JRequest::setVar('cf_wrong_security_code', 1);
if(($session->get('chrono_verification_msg', '', md5('chrono')))
<?php if(($session->get('chrono_verification_msg', '', md5('chrono')))&&(JRequest::getVar('cf_wrong_security_code') == 1)){ ?>