How to restrict a text input to letters?

8 visualizaciones (últimos 30 días)
João Carvalho
João Carvalho el 28 de Nov. de 2017
Editada: the cyclist el 29 de Nov. de 2017
How can I restrict a text input to uppercase and lowercase letters? I have this : new_user.username = input('Username: ', 's');

Respuesta aceptada

the cyclist
the cyclist el 29 de Nov. de 2017
Editada: the cyclist el 29 de Nov. de 2017
Here's one way, taking advantage of the isletter command:
new_user.username = 0;
while ~all(isletter(new_user.username))
new_user.username = input('Username: ', 's');
end

Más respuestas (0)

Categorías

Más información sobre Characters and Strings en Help Center y File Exchange.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by