Guest User

Untitled

a guest
Apr 26th, 2018
60
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.94 KB | None | 0 0
  1. $('input.number').each(function () {
  2. $(this).keypress(function(e){
  3.  
  4. if(e.keyCode == '46' || e.charCode == '46'){
  5.  
  6. if(document.selection){
  7.  
  8. var range = document.selection.createRange();
  9.  
  10. range.text = ',';
  11.  
  12. }else if(this.selectionStart || this.selectionStart == '0'){
  13.  
  14. var start = this.selectionStart;
  15. var end = this.selectionEnd;
  16.  
  17. $(this).val($(this).val().substring(0, start) + ','
  18. + $(this).val().substring(end, $(this).val().length));
  19.  
  20. this.selectionStart = start + 1;
  21. this.selectionEnd = start +1;
  22. }else{
  23.  
  24. $(this).val($(this).val() + ',');
  25. }
  26. return false;
  27. }
  28. });
  29. });
  30.  
  31. <input type="text" class="number"/>
  32.  
  33. <input class="number" type="number" lang="es-ar">
Add Comment
Please, Sign In to add comment