Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <head>
- <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>
- </head>
- <body>
- <form name="atur_harga" action="" method="POST">
- <label for="desimal">Input Desimal :</label>
- <input type="text" class="harga" id="desimal" value="">
- </form>
- <script type="text/javascript">
- $(document).click(function() {
- $(".harga").on("keyup", function() {
- var valid = /^\d{0,15}(\.\d{0,2})?$/.test(this.value),
- val = this.value;
- if (!valid) {
- console.log("Invalid input!");
- this.value = val.substring(0, val.length - 1);
- }
- });
- });
- </script>
- </body>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement