Kshitij Patil
12/22/2020, 3:55 PMCasey Brooks
12/22/2020, 4:27 PM.toUpperCase() on the text when updating the state emitted should do it. The TextField itself doesn’t need to have explicit options for things like this, since you are entirely in control of how it displays and what happens when input is entered
val textState = remember { mutableStateOf(TextFieldValue()) }
TextField(
value = textState.value,
onValueChange = { textState.value = it.copy(text = it.text.toUpperCase()) },
)Kshitij Patil
12/22/2020, 4:54 PMSiyamed
12/22/2020, 4:54 PMDominaezzz
12/22/2020, 5:21 PMSiyamed
12/22/2020, 5:22 PMSiyamed
12/22/2020, 5:22 PMDominaezzz
12/22/2020, 5:25 PMCasey Brooks
12/22/2020, 5:37 PMonValueChange contains non-capital characters, and only assign textState.value if it passes validation
val textState = remember { mutableStateOf(TextFieldValue()) }
TextField(
value = textState.value,
onValueChange = {
if(it.text.matches("[A-Z]*".toRegex())) {
textState.value = it
}
},
)Dominaezzz
12/22/2020, 5:52 PMisErroroValue might have better UX.