Using the client, does anybody have idea about how I can limit the number characters input into a field (limit field size). I know how to do it after the fact, but would like to do it like you can on the web (using JS). Can it be done using JS? like the JS OnKey events?
Subject: Solution with JavaScript an self-calling function (all 0.1 seconds)
Hi Charlie
We realized it with JavaScript. Below you find our example for a field called UnderlyingFacts (ULF) and a display field which shows the remainung number of characters.
HTH, Bodo
Code for field-onBlur
======================
UnderlyingFactsStop = 1 ;
window.document.forms[0].dispULF.value = “” ;
Code for field-onFocus
======================
UnderlyingFactsStop = 0 ;
CheckUnderlyingFacts();
Code for form-JSHeader
======================
// Check max. characters in field
var UnderlyingFactsStop = 1 ;
function CheckUnderlyingFacts(){
frm = window.document.forms[0] ;
var maxLength = frm.ULFmax.value ; // max. characters in field
curLength = frm.UnderlyingFacts.value.length ;
// Timer updates all 0.1 seconds
if ( UnderlyingFactsStop == 0 ){
window.setTimeout(“CheckUnderlyingFacts()”, 100)
};
// display remaining characters
frm.dispULF.value = (UnderlyingFactsStop == 1 ) ? “” : “(remaining " + ((maxLength - curLength<1) ? 0 : maxLength - curLength) + " char.)” ;
// msgbox when maximum is reached
if ( curLength > maxLength ){
alert(“Maximum text length reached (” + maxLength + " char)" )
} ;
frm.UnderlyingFacts.value = frm.UnderlyingFacts.value.substr(0,maxLength) ;
} ;