Skip to content
Advertisement

php email and phone number validation

I currently have the following working code but I need to build on to this some email and phone number validation to make sure it is an actual email and phone number not other data. I have found code to use

JavaScript

but I’m unsure how to incorporate this into my current code. I would love some help with this.

This is my current php code

JavaScript

Advertisement

Answer

This is one example.
I made a foreach with an array just to show you both outputs.

JavaScript

https://3v4l.org/GcKRp

In your case you should probably have it after you check if any of the fields are empty:

JavaScript

Removes non digits and checks if length is less than or equal to 10.

User contributions licensed under: CC BY-SA
7 People found this is helpful
Advertisement