Skip to content
Advertisement

How to validate phone number in laravel?

I want to validate the field of phone number and allow only numbers that start with the following digits 77, 71 , 73 .

How can I implement that in the request that I created?

JavaScript

Advertisement

Answer

One possible solution would to use regex.

JavaScript
  1. I assume your phone number has 9 digits so I used {7} // (71|73|77)2 digits + 7 digits = 9 digits
  2. Notice when you want to use OR, you should use an array instead of separating rules using |
User contributions licensed under: CC BY-SA
5 People found this is helpful
Advertisement