Issue
I want to make my input text field accept alphabets only and space(at least one white space), not only alphabets, i use this expression but only alphabets works but if I put spaces between the text, doesnt work.
const isAlphabet = (input) => {
const re = /^[a-zA-Z]+$/;
return re.test(input);
}
``
Solution
let change /^[a-zA-Z]+$/ for /^[a-z A-Z]+$/. i saw that someone used \s instead of , so i'm still sending my answer, since expression proposed by me is shorter, better performing (due to handling only space) plus u will gain additional knowledge, how to handle spaces in different way.
Answered By - Bartłomiej Stasiak
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.