Every line of 'simple phone number validation in 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.
40 function isValidPhone(value) { 41 return /^[0-9]+$/ig.test(value) 42 }
28 export function phoneValidator(rule, value, callback) { 29 const INVALID_PHONE_MSG = 'Número de telefone inválido'; 30 const PHONE_REGEX = /^\([0-9]*\)\s*[0-9]*\s*-*\s*[0-9]*/i; 31 32 if (!rule.required && !value) { 33 callback(); 34 } 35 36 if (PHONE_REGEX.test(value)) { 37 callback(); 38 } else { 39 callback(INVALID_PHONE_MSG); 40 } 41 }
269 static phone(value) { 270 var reg = /^((\d{10,11})|^((\d{7,8})|(\d{4}|\d{3})-(\d{7,8})|(\d{4}|\d{3})-(\d{7,8})-(\d{4}|\d{3}|\d{2}|\d{1})|(\d{7,8})-(\d{4}|\d{3}|\d{2}|\d{1}))$)$/; 271 return reg.test(value); 272 }
21 export function isValidLength(phone: string): boolean { 22 return phone.length >= PHONE_MIN_LENGTH && phone.length <= PHONE_MAX_LENGTH; 23 }
16 function 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 }
42 public getDigits(phone: string): string { 43 const numbers = phone.match(/\d+/g) 44 if (numbers === null) return '' 45 return numbers.join('') 46 }
312 validPhone() { 313 try { 314 const v = this.phone; 315 return (v && _isValidType('string', v)); 316 } catch (err) { 317 return false; 318 } 319 }
123 function InvalidPhone(){ 124 var invalid_phone_number = $("#invalid-phone-number"); 125 invalid_phone_number.attr("attrHidden", "false"); 126 var need_phone_number = $("#need-phone-number"); 127 need_phone_number.attr("attrHidden", "true"); 128 window.phone_ok = false; 129 }
128 checkWorkPhone: function checkWorkPhone(entry, value) { 129 return !value; 130 },
35 function validateZIPCode(value){ 36 if (!isZIPCode(value)) { 37 alert("Please enter a ZIP code in the form xxxxx."); 38 }; 39 }