+ Start a Discussion
Herish SurendranHerish Surendran 

How to write regex for first name and last name in js of lightning component

var firstnameRegex = "[a-zA-Z]";
       var firstname = component.get("v.First_Name");
       var FirstnameMatch = firstname.match(firstnameRegex);

if(FirstnameMatch == false){
            alert("Please fill in the mandatory details");
        }

I tried this but it didn't work
Deepak_KumarDeepak_Kumar

Hi,
Please add this pattern in your lightning input.

pattern="^[a-zA-Z][a-zA-Z0-9 ]+$".

If this solves your problem. Mark this as the best answer and solved.
Thanks.
Deepak