How to restrict a text input to letters?

3 views (last 30 days)
How can I restrict a text input to uppercase and lowercase letters? I have this : new_user.username = input('Username: ', 's');

Accepted Answer

the cyclist
the cyclist on 29 Nov 2017
Edited: the cyclist on 29 Nov 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

More Answers (0)

Categories

Find more on Characters and Strings in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!