Phone Mask
How do I make an phone mask?
What is a phone mask? How do you make a phone mask? This script and codes were developed by Kyle Michael Sullivan on 21 September 2022, Wednesday.
Phone Mask - Script Codes HTML Codes
<!DOCTYPE html>
<html >
<head> <meta charset="UTF-8"> <title>Phone Mask</title> <link rel="stylesheet" href="css/style.css">
</head>
<body> <label for="phone">Phone</label>
<input type="text" id="phone" onKeyUp="phoneMask(event)">
<button type="button" onClick="document.getElementById('phone').value=null">X</button> <script src="js/index.js"></script>
</body>
</html>
Phone Mask - Script Codes CSS Codes
label { font-weight:bold
}
Phone Mask - Script Codes JS Codes
function phoneMask(event) { var e = event.which; var P = document.getElementById("phone").value.replace(/\D+/g, ''); var L = P.length; if (e == 8) { // 8:backspace if (L < 11) { document.getElementById("phone").value = "(" + P.substring(0,3) + ") " + P.substring(3,6) + "-" + P.substring(6,10); } if (L < 7) { document.getElementById("phone").value = "(" + P.substring(0,3) + ") " + P.substring(3,6); } if (L < 4) { document.getElementById("phone").value = "(" + P.substring(0,3); } if (L < 1) { document.getElementById("phone").value = ""; } } else { if (L < 1) { document.getElementById("phone").value = null; } else if (L < 3) { document.getElementById("phone").value = "(" + P; } else if (L == 3) { document.getElementById("phone").value = "(" + P + ") "; } else if (L < 6) { document.getElementById("phone").value = "(" + P.substring(0,3) + ") " + P.substring(3,6); } else if ( L == 6) { document.getElementById("phone").value = "(" + P.substring(0,3) + ") " + P.substring(3,6) + "-"; } else if ( L < 11) { document.getElementById("phone").value = "(" + P.substring(0,3) + ") " + P.substring(3,6) + "-" + P.substring(6,10); } else { document.getElementById("phone").value = "(" + P.substring(0,3) + ") " + P.substring(3,6) + "-" + P.substring(6,10) + " x" + P.substring(10,13); } }
}
Developer | Kyle Michael Sullivan |
Username | GPMCTO |
Uploaded | September 21, 2022 |
Rating | 3 |
Size | 1,850 Kb |
Views | 22,264 |
Find the perfect freelance services for your business! Fiverr's mission is to change how the world works together. Fiverr connects businesses with freelancers offering digital services in 500+ categories. Find Developer!
Name | Size |
JS Greeting | 1,792 Kb |
A Pen by Kyle Michael Sullivan | 1,437 Kb |
JQuery UI Slider | 3,126 Kb |
Bed Matrix | 1,952 Kb |
Jasper is the AI Content Generator that helps you and your team break through creative blocks to create amazing, original content 10X faster. Discover all the ways the Jasper AI Content Platform can help streamline your creative workflows. Start For Free!
Name | Username | Size |
Smoke Shader - Frame Buffer | Omarshe7ta | 2,672 Kb |
STAR WARS LIGHTSABER | Francoiscoron | 4,420 Kb |
IbrahimJabbari-Effect21 | Ibrahimjabbari | 1,882 Kb |
Rows with image hover effect | Amit-webdesigner | 12,875 Kb |
Pure CSS Tooltip | APinix | 2,815 Kb |
Fluid Responsive Typography | Jonmilner | 4,205 Kb |
Simple checkbox style | Vncnz | 2,628 Kb |
SlideupBoxes | Gavra | 23,772 Kb |
Headroom.js demo | WickyNilliams | 3,982 Kb |
A Pen by Adrien Clerbois | AClerbois | 6,501 Kb |
Surf anonymously, prevent hackers from acquiring your IP address, send anonymous email, and encrypt your Internet connection. High speed, ultra secure, and easy to use. Instant setup. Hide Your IP Now!