Search the archives!
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Javascript] maxLength question
- From: edwin at bitstorm.org (Edwin Martin)
- Subject: [Javascript] maxLength question
- Date: Sat May 19 08:23:17 2007
DeWayne Crenshaw,
> function changeLength()
> {
> if (document.myForm.radioButton[1].checked) {maxLength
> =5}
> else {maxLength =6}
> }
>
> <INPUT TYPE=TEXT NAME="textBox" id="textBox"
> onfocus="changeLength()">
>
> I'm looking for something that will work cross-browser
> and would appreciate any pointers.
>
1) In the code above, you only set the value of the variable maxLength.
To set the length of an element, you have to do something like:
document.myForm.myInput.maxlength = 5;
2) Do not use the onfocus eventhandler for this, because it's possible to change the checkbox without the onfocus-handler being called for a second time.
Edwin Martin
--
http://www.bitstorm.org/edwin/en/
- Follow-Ups:
- [Javascript] maxLength question
- From: DeWayne Crenshaw
- [Javascript] maxLength question
- References:
- [Javascript] maxLength question
- From: DeWayne Crenshaw
- [Javascript] maxLength question
- Prev by Date: [Javascript] maxLength question
- Next by Date: [Javascript] maxLength question
- Previous by thread: [Javascript] maxLength question
- Next by thread: [Javascript] maxLength question
- Index(es):