Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <!DOCTYPE html>
- <html>
- <head>
- <meta charset="utf-8">
- <meta name="viewport" content="width=device-width">
- <title>Remove Commas</title>
- </head>
- <body>
- <p>Field 1 (No Commas): <input type="text" id="test1" class="no-commas"></p>
- <p>Field 2 (Commas OK): <input type="text" id="test2"></p>
- <p>Field 3 (No Commas): <input type="text" id="test3" class="no-commas"></p>
- <p>We take commas out of all fields with the css class "no-commas".</p>
- <script>
- var list = document.getElementsByClassName("no-commas");
- for (var i = 0; i < list.length; i++) {
- list[i].onblur = function() {
- this.value = this.value.replace(/,/g, '');
- }
- }
- </script>
- </body>
- </html>
Add Comment
Please, Sign In to add comment