Adding Custom Form Validation for a Full Name input field


#1

Hey guys,
I tried using the code below for a Full Name validation in a single input field with a space between the texts(a space between the first and second name). But for some reasons I couldn’t make it work! Will you please kindly have a look at it?

This is the code:

And this is my landing page: http://unbouncepages.com/pradaxa-one/

Thanks.


#2

Hi @Nayon,

The problem is with your regex validation rule. Currently, any single character would validate it.

I would strongly advise against validating Full Name since it would open you up to a world of edge cases.

However, if you still want to proceed just Google a proper full name regex validation.

Best,
Hristian


#3

Hello Hristian,
Thanks for your quick response!
I understand the complexity with it but I still need to do it!

And I followed your suggestion of Googling it. And found this:

But I am not really a javascript guy! I don’t know how to put it in my above code. Will you please kindly help me here?


#4

Actually I solved it! with this code:


#5

Hi @Nayon,

I’m happy you’ve found a solution but like I said any regex checking a full name would open up dozens of edge cases.

Your current implementation doesn’t account for names having: hyphens (common in last names), more than 2 names, names with apostrophes and probably a bunch of other variations.

Best,
Hristian


#6

Yeah, I totally understand why you told me not to go with it! But my client demanded even after hearing what complications it might bring in!
So, had to do it.

Thanks for you suggestions and replies man.