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 |
RoundUp Rumble 2015 | 6,519 Kb |
Spotlight Animation | 1,811 Kb |
Background Color Switcher | 1,955 Kb |
Super cool hover section links | 3,317 Kb |
Cool Form Labels | 1,716 Kb |
CSS Dot Leaders | 2,803 Kb |
Shaun Spills | 2,770 Kb |
IOS Style Underline | 2,414 Kb |
Neural Colors | 4,213 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 |
Comment Jquery | SquishyAndroid | 2,421 Kb |
Blockquote design | Sjmcpherson | 1,863 Kb |
Day 11 - Calendar Card | Arnellebalane | 6,984 Kb |
Css or Czz.. | Judag | 4,111 Kb |
Base-Style | Daniel_gooss | 2,614 Kb |
Flower expansion | Sreucherand | 3,425 Kb |
Marching Squares Visualized | Sakri | 7,074 Kb |
Layout 11 | Altynai | 1,690 Kb |
Animated Vertical CSS3 Menu Black | MaCeLMp4 | 2,750 Kb |
Automatic scroll | Skeurentjes | 4,042 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!