Skip to main content
Version: Next

isPhoneNumber

Using this method, you can check whether the received input is a phone number or not

Params

isPhoneNumber(str, options = { ignoreCountryCode: false });
  • str → str Write the string you want to check whether it is an phone number or not in this parameter and pass it to the function
  • ignoreCountryCode → ignoreCountryCode The entry should be checked without country code - this value is false by default

Returns

true | false
  • Boolean → If the input string is a PhoneNumber, it returns true and if the input string is not a PhoneNumber, it returns false.

Usage

isPhoneNumber("09121234567"); //false

isPhoneNumber("+989121234567"); //true

isPhoneNumber("9121234567",{ignoreCountryCode : true}); //true

isPhoneNumber("09121234567", { ignoreCountryCode: true }); //true

isPhoneNumber("9121234567"); //false

isPhoneNumber("+989121234567"); //true