Converting Users Input to Title Case

Hello, I want to make one of my input fields on a form either convert the sentence into title case, where the first letter of each word is capitalized, or send an error to the user when it is not in title case before they can save the form. Does anyone know how to do this? Thanks!  
2 answers

It’s possible in Mendix, but you need less readable logic:

  • Split string into words
  • Loop the words
    • Get the first character
    • Uppercase this character

In my opinion it’s better to create a Java Action and use the WordUtils library with capitalize() or capitalizeFully(). Examples are available here:

You can call the Java Action in an OnChange microflow or just before your save action.




Hi Molly,

You can add an ‘on leave’ or ‘on change’ event on the input field to trigger a microflow. In the microflow you can change the member with the toUppercase() function in combination with substring(). 
So for example if you want to change the word ‘hello’ to your specifications you would do the following:

toUppercase(substring($variable,0,1)) + substring($variable,1)

Also see:

Good luck!