Monday, September 20, 2010

Sharepoint: Max Character Limit

How to set the maximum field length in InfoPath
by S.Y.M. Wong-A-Ton
Learn how you can use a data validation condition to check the maximum field length in InfoPath and display an error message to the user if the maximum field length is exceeded.
If you’re used to programming in Visual Studio, you’ll be disappointed to know that there is no MaxLength property that you can set on fields in InfoPath that can hold multiple lines of text with line breaks.
So if you want to set the maximum field length on a multi-line InfoPath Text Box (that allows line breaks) or Rich Text Box, you must use data validation.
Note: You can limit the amount of characters on a single-line text box by going to the Properties dialog box of the text box, clicking on the Display tab, and selecting the Limit text box to checkbox.
When using data validation to restrict the maximum field length in InfoPath, you can use the string-length function in a The expression data validation condition to check whether the amount of characters entered in a field is greater than the maximum characters allowed, and then display an error message.
For example, in Figure 1, I’ve created a data validation condition to check whether the maximum length of a piece of text in a multi-line text box (field1) exceeds 10 characters. This technique also works for rich text boxes in InfoPath.
Caveat: Spaces and line breaks are counted as characters.

No comments: