Field Validator - Number & Leading 0s
How do I make an field validator - number & leading 0s?
Two examples of jQuery implementation of field validation. It only allows numerical input (both row and keypad) and will add leading 0s (up to 10 digits) to the entered value. . What is a field validator - number & leading 0s? How do you make a field validator - number & leading 0s? This script and codes were developed by Casey Hunt on 19 November 2022, Saturday.
Field Validator - Number & Leading 0s - Script Codes HTML Codes
<!DOCTYPE html>
<html >
<head> <meta charset="UTF-8"> <title>Field Validator - Number & Leading 0s</title> <link rel="stylesheet" href="css/style.css">
</head>
<body> <form> <input type="text" id="text" maxlength="10" /> <input type="text" id="text2" maxlength="10" />
</form> <script src='http://cdnjs.cloudflare.com/ajax/libs/jquery/2.1.3/jquery.min.js'></script> <script src="js/index.js"></script>
</body>
</html>
Field Validator - Number & Leading 0s - Script Codes CSS Codes
body { background-color: #ccc;
}
Field Validator - Number & Leading 0s - Script Codes JS Codes
$('#text').keydown(function (event) { if (event.keyCode > 57) { if (event.keyCode < 96 || event.keyCode > 105) { event.preventDefault(); } }
});
$('#text').blur( doPad(10) );
function doPad(length) { return function() { var str = this.value; while (str.length < length) { str = '0' + str; } this.value = str; }
}
/////////////////////////////
// Way sexier way to do it //
$('#text2').on('blur', { to: 10 }, pad );
function pad(e) { var val = this.value + ''; this.value = Array( e.data.to - ( val.length - 1 ) ).join('0') + val;
}
Developer | Casey Hunt |
Username | caseymhunt |
Uploaded | November 19, 2022 |
Rating | 3 |
Size | 1,973 Kb |
Views | 14,168 |
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 |
Shaun Spills | 2,770 Kb |
CSS Only radio image label | 2,114 Kb |
Super cool hover section links | 3,317 Kb |
Headroom.js Test | 2,298 Kb |
IOS Style Underline | 2,414 Kb |
Spotlight Animation | 1,811 Kb |
CSS Dot Leaders | 2,803 Kb |
RoundUp Rumble 2015 | 6,519 Kb |
A Pen by Casey Hunt | 1,925 Kb |
JQuery Time Range Slider | 3,055 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 |
Halo 5 REQ Guide Bookmarklet | Cwacht | 3,993 Kb |
Portfolio Page | KaylaMT | 1,983 Kb |
Navcube | Wbarlow | 4,775 Kb |
SVG Text Masking | JMChristensen | 2,141 Kb |
IbrahimJabbari-Effect14 | Ibrahimjabbari | 1,919 Kb |
Sticky div | Kaslab | 2,225 Kb |
CSS3 Diamond | Rendro | 1,960 Kb |
Wikipedia viewer | Chpecson | 2,865 Kb |
SVG email test v2.0 | M_J_Robbins | 2,090 Kb |
Gradient-ui-button-mark-fx | Tabspace | 1,881 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!