Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

javascript phone number mask

// JAVASCRIPT
document.getElementById('phone').addEventListener('input', function (e) {
  var x = e.target.value.replace(/D/g, '').match(/(d{0,3})(d{0,3})(d{0,4})/);
  e.target.value = !x[2] ? x[1] : '(' + x[1] + ') ' + x[2] + (x[3] ? '-' + x[3] : '');
});

// HTML
<input type="text" id="phone" placeholder="(555) 555-5555"/>
Comment

PREVIOUS NEXT
Code Example
Javascript :: Clear Cell Value In Google Sheet By App Scripts 
Javascript :: import resolver path react 
Javascript :: replace object in array javascript 
Javascript :: get previous route 
Javascript :: jquery checkbox checked or not 
Javascript :: replace all dashes to slashes using jquery in a string 
Javascript :: js check if obj all false 
Javascript :: js indexof nested array 
Javascript :: javascript last element of array 
Javascript :: how to loop object javascript 
Javascript :: insertbefore jquery 
Javascript :: focus js 
Javascript :: get minutes and seconds from seconds 
Javascript :: get total height of page javascript 
Javascript :: nextjs path alias 
Javascript :: js sort asendenet 
Javascript :: js check if date is future 
Javascript :: submit form automatically javascript 
Javascript :: node get current url 
Javascript :: moment js year only 
Javascript :: make keystore 
Javascript :: back button js 
Javascript :: `object` ("[object Object]") cannot be serialized as JSON. Please only return JSON serializable data types 
Javascript :: encodeurl in javascript 
Javascript :: javascript get class of body 
Javascript :: jqurey cdn 
Javascript :: React’ must be in scope when using JSX react/react-in-jsx-scope 
Javascript :: deep copy object/array 
Javascript :: how to import jquery in js file 
Javascript :: infinite for loop javascript 
ADD CONTENT
Topic
Content
Source link
Name
7+9 =