Guest User

Untitled

a guest
Mar 22nd, 2018
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.66 KB | None | 0 0
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <meta charset="utf-8">
  5. <meta name="viewport" content="width=device-width">
  6. <title>Remove Commas</title>
  7. </head>
  8. <body>
  9. <p>Field 1 (No Commas): <input type="text" id="test1" class="no-commas"></p>
  10. <p>Field 2 (Commas OK): <input type="text" id="test2"></p>
  11. <p>Field 3 (No Commas): <input type="text" id="test3" class="no-commas"></p>
  12.  
  13. <p>We take commas out of all fields with the css class "no-commas".</p>
  14.  
  15. <script>
  16. var list = document.getElementsByClassName("no-commas");
  17. for (var i = 0; i < list.length; i++) {
  18. list[i].onblur = function() {
  19. this.value = this.value.replace(/,/g, '');
  20. }
  21. }
  22. </script>
  23. </body>
  24. </html>
Add Comment
Please, Sign In to add comment