Splits

When writing programs, just a little bit of extra thought can produce exponential UX gains.

Say we want to take input of two values, separated by a space. We make an input field, and tell the user to .... input two values separated by space. But users don't read. They try first and ask questions only when they're frustrated the input isn't sufficiently intuitive. It doesn't have to be this way! With very little effort an input can split fields in a more forgiving manner.

// don't do this:
let values = text.split(" ")
// do this:
let values = text.split(/[ ,:\/;-]+/)

The end result is the user can type pretty much anything as a delimiter between the fields, and it'll work out just fine. CAVEAT - as long as the list of acceptable delimiters does not include any characters that would be valid for the type of input expected.

text = "ONE,TWO"
text = "ONE, TWO"
text = "ONE TWO"
text = "ONE - TWO"
text = "ONE::TWO"
//User doesn't have to worry about the delimiter. They input
//whatever feels natural to them, and it just works!