skip to Main Content

I’m comming with a little question here. I need to do something to validate the a name in the registration form, until now I did this :

if(TextUtils.isEmpty(textFullName) )

and this

else if(!textFullName.matches("[a-zA-Z ]+"))

but those are for empty and alphabetic characters, the problem is that I can’t have spaces between names like : " Bill Bob" ( it works only if they are together : "BillBob" ) and another thing is that I want this symbol : "-" , because some names have it, like : "Bill-Bob".
Thank you for helping me out!

2

Answers


  1. The regex should also include space(\s) and -

    else if(!textFullName.matches("[a-zA-Z\s-]+"))
    
    Login or Signup to reply.
  2. asdf asfdsafv sdfasdfasdfasdf sadlf kasfkdl asdfh hasfoiasf ,asdij fl i;adsfjo f s dasd

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search