MaxLength Property

Gets or sets the maximum number of characters that will be sent back to the host.

object.MaxLength = [integer]

Where object is an object expression that evaluates to one of the controls in the Applies To list, and integer is the maximum number of characters that the field will accept.

Client support

   Newlook Smartclient

   Newlook Server

Use

This property can be used to return the maximum number of characters that the field will accept or limit the number of characters that can be entered into a field at run-time (i.e. restricting the maximum number of characters that will be sent back to the host).

Default value

When a user enters individual characters into a field using the keyboard, data entry is prevented as soon as the number of characters exceeds the MaxLength.

When a user attempts to enter a value that is longer than the MaxLength; as a result of a paste action, by selecting an item from a drop down or by dynamically populating the field; entry will be prevented.

BE AWARE:

Setting the MaxLength property of a host-generated field to a value greater than the host field's length will enable the user to enter a greater number of characters into the field than the field can accept. At the point at which the value is sent back to the host, the value will be truncated to the number of character the field will accept.

TIP:

Changing the MaxLength property in Designer will not affect the control's default value sent through from the host. It will however, affect any subsequent changes to the control's value at run-time. For example, if a field is received from the host with the value 1234 and the MaxLength property of that field has been set to 3, then the value sent through from the host, 1234, will remain unchanged but any changes to this value at run-time will be restricted to 3 characters.

Additional considerations

SignedNum Format

Where a field's Format property is set to FormatSignedNum, the MaxLength includes one character reserved for the sign. Therefore setting MaxLength to 5 will allow the user to enter up to four numeric characters plus an (optional) sign.

CLIENT DIFFERENCES:

Newlook Server does not differentiate between the keystrokes entered into a field at the time of data entry. This means that the field's contents are not validated until the field is submitted to the host. This is different to Newlook Smartclient, where key validation is performed per keystroke, and the data is checked for validity according to the Format type and MaxLength of the field. As an example, for a SignedNum field with a MaxLength of 5, Newlook Server will allow the user to enter 5 numeric characters into the field, but then truncate the value when it is submitted. Newlook Smartclient will only allow 4 numeric characters and a sign.

DBCS fields

For DBCS fields, the MaxLength property represents the single-byte character length of the field. This does not necessarily equate to the number of characters that can be entered into the field, as that will depend on whether the entered characters are single-byte or double-byte, and also on the DBCS type of the field.

See Also

Format property | Len function | PasswordChar property | Text property | ReferenceField property

Applies To

Combo box control | Date combo box control | Numeric combo control | Text box control


© 2004-2021 looksoftware. All rights reserved.