10 examples of '10 digit mobile number validation using javascript' in JavaScript

Every line of '10 digit mobile number validation using javascript' code snippets is scanned for vulnerabilities by our powerful machine learning engine that combs millions of open source libraries, ensuring your JavaScript code is secure.

All examples are scanned by Snyk Code

By copying the Snyk Code Snippets you agree to
this disclaimer
21export function isValidLength(phone: string): boolean {
22 return phone.length >= PHONE_MIN_LENGTH && phone.length <= PHONE_MAX_LENGTH;
23}
Important

Use secure code every time

Secure your code as it's written. Use Snyk Code to scan source code in minutes – no build needed – and fix issues immediately. Enable Snyk Code

42public getDigits(phone: string): string {
43 const numbers = phone.match(/\d+/g)
44 if (numbers === null) return ''
45 return numbers.join('')
46}
40function isValidPhone(value) {
41 return /^[0-9]+$/ig.test(value)
42}
28export function looksValid(phoneNumber) {
29 return PHONE_NUMBER_REGEXP.test(phoneNumber);
30}
92var validNumeric = function validNumeric(number) {
93 var numbers = /^[0-9۰-۹٠-٩]+$/;
94 if (number.toString().replace(/,/g, '').match(numbers)) {
95 return true;
96 } else {
97 return false;
98 }
99};
7function checkMobile(phone_val){
8 var pattern=/(^(([0\+]\d{2,3}-)?(0\d{2,3})-)(\d{7,8})(-(\d{3,}))?$)|(^0{0,1}1[3|4|5|6|7|8|9][0-9]{9}$)/;
9 return pattern.test(phone_val);
10}
2isAcceptable(s: string) {
3 return s.length === 5 && parseInt(s).toString() === s;
4}
4return function luhn (number) {
5 if (!number) return false;
6 var length = number.length;
7 var bit = 1;
8 var sum = 0;
9 var value;
10
11 while (length) {
12 value = parseInt(number.charAt(--length), 10);
13 sum += (bit ^= 1) ? array[value] : value;
14 }
15
16 return sum && sum % 10 === 0;
17};
16function js_phone( phone )
17{
18 if ( parseInt( phone ) == 0 )
19 return '';
20 var len = phone.length;
21 var result = phone;
22 if ( len > 10 )
23 result = result.insert( -10, ' (' ).insert( -7, ') ');
24 if ( len > 4 )
25 result = result.insert( -4, '-' ).insert( -2 , '-' );
26 return ( len > 10 ? '+' : '' ) + result;
27}
790function isPhoneNumber(number) {
791 var regex = /^\(?([0-9]{3})\)?[-. ]?([0-9]{3})[-. ]?([0-9]{4})$/;
792 return regex.test(number);
793}

Related snippets