679Chapter 23Text-Related Form ObjectsmaxLengthValue:Integer.Read/WriteCompatibility:WinIE4+, MacIE4+, NN6+, Moz1+, Safari1+ (Cheap web hosting)
679Chapter 23Text-Related Form ObjectsmaxLengthValue:Integer.Read/WriteCompatibility:WinIE4+, MacIE4+, NN6+, Moz1+, Safari1+ The maxLengthproperty controls the maximum number of characters allowed to be typedinto the field. There is no interaction between the maxLengthand sizeproperties. This valueis normally set initially via the maxlengthattribute of the inputelement. Use The Evaluator (Chapter 13) to experiment with the maxLengthproperty. The top textfield has no default value, but you can temporarily set it to only a few characters and see howit affects entering new values: document.forms[0].input.maxLength = 3; Try typing this into the field to see the results of the change. To restore the default value, reload the page. Related Items:sizeproperty. nameValue:Identifier string.Read/WriteCompatibility:WinIE3+, MacIE3+, NN2+, Moz1+, Safari1+ Text object names are important for two reasons. First, if your HTML page submits informa- tion to CGI scripts, the input device passes the name of the text object along with the data tohelp the server program identify the data being supplied by the form. Second, you can use atext object s name in its reference within JavaScript coding. If you assign distinctive, meaning- ful names to your fields, these names will help you read and debug your JavaScript listings(and will help others follow your scripting tactics). Be as descriptive about your text object names as you can. Borrowing text from the field s on- page label may help you mentally map a scripted reference to a physical field on the page. Like all JavaScript object names, text object names must begin with a letter and be followedby any number of letters or numbers. Avoid punctuation symbols with the exception of thevery safe underscore character. Although I urge you to use distinctive names for all objects you define in a document, you canmake a case for assigning the same name to a series of interrelated fields and JavaScript isready to help. Within a single form, any reused name for the same object type is placed in anindexed array for that name. For example, if you define three fields with the name entry, thefollowing statements retrieve the valueproperty for each field: data = document.forms[0].entry[0].value; data = document.forms[0].entry[1].value; data = document.forms[0].entry[2].value; This construction may be useful if you want to cycle through all of a form s related fields todetermine which ones are blank. Elsewhere, your script probably needs to know what kind ofinformation each field is supposed to receive, so that it can process the data intelligently. Idon t often recommend reusing object names, but you should be aware of how the objectmodel handles them in case you need this construction. See Form element arrays inChapter 21 for more details. Consult Listing 23-2 later in this chapter, where I use the text object s name, convertor, aspart of the reference when assigning a value to the field. To extract the name of a text object, document.formObject.textObject.name
You need excellent and relaible webhost company to host your web applications? Then pay a visit to Inexpensive Web Hosting services.