Closed Thread Icon

Topic awaiting preservation: Releasing the maxLength limit (Page 1 of 1) Pages that link to <a href="https://ozoneasylum.com/backlink?for=8044" title="Pages that link to Topic awaiting preservation: Releasing the maxLength limit (Page 1 of 1)" rel="nofollow" >Topic awaiting preservation: Releasing the maxLength limit <span class="small">(Page 1 of 1)</span>\

 
hlaford
Bipolar (III) Inmate

From: USA! USA! USA!
Insane since: Oct 2001

posted posted 01-25-2002 01:00

How do I reset the maxLength of a text field? i've tried setting to null, but that makes the field uneditable. ideas?

Bugimus
Maniac (V) Mad Scientist

From: New California
Insane since: Mar 2000

posted posted 01-25-2002 05:33

<input type="text" id="time" value="0" size="3" maxlength="2">

document.getElementById("time").value=0
document.getElementById("time").maxLength=1
document.getElementById("time").size=2

You should set maxLength to greater to zero if you want to edit it. It determines how many characters can be typed into a field.

Is that what you are asking for?


Slime
Lunatic (VI) Mad Scientist

From: Massachusetts, USA
Insane since: Mar 2000

posted posted 01-25-2002 06:23

Or did you want to eliminate the length restriction altogether?

If that's the case, you might try setting it to Number.POSITIVE_INFINITY... actually, I'm not sure if you're allowed to use that property of the Number object, but try Number.MAX_VALUE (the highest possible number allowed in JavaScript). If that doesn't work either, just use 99999 or something.

hlaford
Bipolar (III) Inmate

From: USA! USA! USA!
Insane since: Oct 2001

posted posted 01-25-2002 17:14

I ended up just alerting the default value (which is 2147483647) and assigning it to a global definition:

code:
var INPUT = {maxLength: 2147483647};

document.elements[n].maxLength = INPUT.maxLength;



using Number.MAX_VALUE and Number.POSITIVE_INFINITY causes the field to be uneditable also.

Bugimus
Maniac (V) Mad Scientist

From: New California
Insane since: Mar 2000

posted posted 01-25-2002 22:54

Just out of curiosity, what kind of input are you expecting to get into those fields? The max integer is larger than most input I can imagine. I guess it's best to be safe though, so you're doing the right thing.

Slime
Lunatic (VI) Mad Scientist

From: Massachusetts, USA
Insane since: Mar 2000

posted posted 01-26-2002 00:10

Interesting. 2^31 - 1. Almost makes sense, but it's as if it's allowing negative numbers... oh, I know why. Cool. I believe that's the highest number allowed in JavaScript.

« BackwardsOnwards »

Show Forum Drop Down Menu