function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ 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