PDA

View Full Version : Form field Limiter - Enter worth 2 help



Knud
05-05-2005, 06:54 AM
Script: DD Tab Menu
http://www.dynamicdrive.com/dynamicindex16/limitinput.htm

I'm just using the "Form field Limiter" script and have a problem that I can't work out.
I need to change the counting section of the script so that the enter key is worth 2 characters instead of 1.

I really have no idea how to change this could someone post me some code to help me please.

A handy addon for this script I did work out was to change the value of the number of text limited if there is text in the form element when the page is loaded.

e.g.

*****************
function displaylimit(thename, theid, thelimit, currentlimit){
var theform=theid!=""? document.getElementById(theid) : thename
var limit_text='<span id="'+theform.toString()+'">'+currentlimit+'</span> characters remaining'
if (document.all||ns6)
document.write(limit_text)
if (document.all){
eval(theform).onkeypress=function(){ return restrictinput(thelimit,event,theform)}
eval(theform).onkeyup=function(){ countlimit(thelimit,event,theform)}
}
else if (ns6){
document.body.addEventListener('keypress', function(event) { restrictinput(thelimit,event,theform) }, true);
document.body.addEventListener('keyup', function(event) { countlimit(thelimit,event,theform) }, true);
}
}
****************

the currentlimit value can be worked out when creating the page asp etc. This helps if you are changing or updating information.

Knud
05-26-2005, 02:25 AM
Could someone point me in the right direction to solve this problem.

jscheuer1
05-26-2005, 08:04 AM
In IE6 my enter key sends a carriage return and line feed so it already counts as two on the demo page for this script. Most folks use IE6. In FF only one is sent but, either is interpreted as a line break and if selected, copied and pasted on a windows based machine is interpreted as both. If it were me, I'd just live with it. Why is it so critical?