Skip to main content
se eliminaron 67 caracteres en el cuerpo
Origen Enlace
zerokira
  • 1.9k
  • 4
  • 16
  • 39

$(document).ready(function () {
    $('.solo-numero').keyupon('input', function () {
       
  this.value = (this.value + '').replace(/[^0-9]/g, '');
    });
});
<!DOCTYPE html>
<html>
<head>
<meta name="description">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
  <meta charset="utf-8">
  <meta name="viewport">
  <title>JS Bin</title>
</head>
<body>
<input type="text" class="solo-numero" name="algo">


</body>
</html>

Espero que te funcione si algo me comentas.

$(document).ready(function () {
    $('.solo-numero').keyup(function () {
        this.value = (this.value + '').replace(/[^0-9]/g, '');
    });
});
<!DOCTYPE html>
<html>
<head>
<meta name="description">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
  <meta charset="utf-8">
  <meta name="viewport">
  <title>JS Bin</title>
</head>
<body>
<input type="text" class="solo-numero" name="algo">


</body>
</html>

Espero que te funcione si algo me comentas.

$('.solo-numero').on('input', function () {  
  this.value = this.value.replace(/[^0-9]/g,'');
});
<!DOCTYPE html>
<html>
<head>
<meta name="description">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
  <meta charset="utf-8">
  <meta name="viewport">
  <title>JS Bin</title>
</head>
<body>
<input type="text" class="solo-numero" name="algo">


</body>
</html>

Espero que te funcione si algo me comentas.

Origen Enlace
zerokira
  • 1.9k
  • 4
  • 16
  • 39

$(document).ready(function () {
    $('.solo-numero').keyup(function () {
        this.value = (this.value + '').replace(/[^0-9]/g, '');
    });
});
<!DOCTYPE html>
<html>
<head>
<meta name="description">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
  <meta charset="utf-8">
  <meta name="viewport">
  <title>JS Bin</title>
</head>
<body>
<input type="text" class="solo-numero" name="algo">


</body>
</html>

Espero que te funcione si algo me comentas.