Reputation: 1124
How to force outLineTxtFieldValue to accept only numbers ?.
For example,
user can only enter numbers, not a negative value. We can enter numbers such as
120
,
1
,
9
,
10012
,
in short, we can say positive integers
or natural numbers
in kotlin compose outlinetextfield
or textfield
Upvotes: 0
Views: 1253
Reputation: 1025
Simply display the keyboard with only numbers:
TextField(
value = textState,
onValueChange = { text ->
textState = text
},
keyboardOptions = KeyboardOptions.Default.copy(
keyboardType = KeyboardType.NumberPassword
),
visualTransformation = VisualTransformation.None
)
Upvotes: 0
Reputation: 125
TextField(
keyboardOptions = KeyboardOptions(keyboardType = KeyboardType.Number)
Upvotes: 1