In this article we'll create a text input field and set a couple of rules.
The first rule is that the first character must be 0 and If it's not, we'll change whatever the character is to 0.
The second rule is that the number must be 10 digits long and we'll display a count as the user types.
What we won't cover in this article is ensuring that the user only types in numbers.
As always, whenever you intend to use jQuery in your project please make sure the library is included. Including jQuery can be as simple as pasting the integration code from the CDN like this:
<script src="https://code.jquery.com/jquery-3.3.1.min.js" integrity="sha256-FgpCb/KJQlLNfOu91ta32o/NMZxltwRo8QtmkMRdAu8=" crossorigin="anonymous"></script>
<!-- The HTML form input --> <input id="number" type="text" placeholder="Please enter a 10 digit number"> <!-- Count the number of digits remaining --> <div id="remaining">Remaining: <span id="count"></span></div>