P
pduncan
Hi everyone,
I have a countChars function (javascript) for my textarea box: The
functions uses a textarea, and textbox. User is only allowed to type
up to "maxLength" characters in the textarea and the characters
remaining is displayed in the textbox.
function countChars(controlToValidateRef,
maxLength,outputControlRef, errorMessage,
enableClientSideRestriction,showJavascriptAlert,showCharacterCount)
{
var countString = maxLength - controlToValidateRef.value.length;
if (countString < 0) {
if (enableClientSideRestriction) {
controlToValidateRef.value =
controlToValidateRef.value.substring( 0, maxLength );
if (showJavascriptAlert) {
alert(errorMessage);
}
return false;
}
} else {
if (showCharacterCount) {
outputControlRef.value = countString;
}
}
}
I'm using this function for the following events
(onkeyup,onChange,OnFocus,OnBlur) of the textarea
This works in every scenario, except when a user uses the browser to
paste in text. Any way to detect this???
Thanks,
Paul
I have a countChars function (javascript) for my textarea box: The
functions uses a textarea, and textbox. User is only allowed to type
up to "maxLength" characters in the textarea and the characters
remaining is displayed in the textbox.
function countChars(controlToValidateRef,
maxLength,outputControlRef, errorMessage,
enableClientSideRestriction,showJavascriptAlert,showCharacterCount)
{
var countString = maxLength - controlToValidateRef.value.length;
if (countString < 0) {
if (enableClientSideRestriction) {
controlToValidateRef.value =
controlToValidateRef.value.substring( 0, maxLength );
if (showJavascriptAlert) {
alert(errorMessage);
}
return false;
}
} else {
if (showCharacterCount) {
outputControlRef.value = countString;
}
}
}
I'm using this function for the following events
(onkeyup,onChange,OnFocus,OnBlur) of the textarea
This works in every scenario, except when a user uses the browser to
paste in text. Any way to detect this???
Thanks,
Paul