Automatically change the first letter of a word/sentence to upper case
Use the concat(), substring(), translate(), and string-length() function within a formula to convert the first letter in a word or sentence.
When an InfoPath user types in the text "example" or "this is really cool!", you would like this text to automatically be changed into "Example" or "This is really cool!" when the user leaves the text field.
Use the concat(), substring(), translate(), and string-length() functions in a formula to format the text field.
You can accomplish this functionality as follows:
- Create a New Blank Form in InfoPath.
- Add a Text Box control to the form.
- Double-click on the text box control to open its Properties dialog box.
- Click on the Insert Formula button behind the Default Value field.
- Enter the following formula on the Insert Formula dialog box:
concat(substring(translate(., "abcdefghijklmnopqrstuvwxyz", "ABCDEFGHIJKLMNOPQRSTUVWXYZ"), 1, 1), substring(., 2, string-length(.) - 1))
- Click on the OK button when closing all open dialog boxes.
The first letter of a word or sentence typed into the text box should now automatically be converted into an upper case letter whenever the text box loses the focus.
Copyright: This article may not be used on web sites (whether personal or otherwise), copied, disseminated, altered, printed, published, broadcasted, or reproduced in any way without an expressed written consent of S.Y.M. Wong-A-Ton. The techniques demonstrated in this article may be used within any Microsoft InfoPath project. This article is provided without any warranties. Copyright for this article is non-transferrable and remains with the author, S.Y.M. Wong-A-Ton.
Related InfoPath Articles:
- Auto-fill fields in InfoPath from a drop-down list box selection and secondary data source
- Auto-formatting a time field in InfoPath when it loses the focus
- InfoPath functions with examples
- InfoPath 2010 functions within functions in a formula
- InfoPath 2013 LEFT and RIGHT functions