JSFiddle - React, Tailwind, and code Playground

by Alexis López Espinoza

HTML

<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.2/jquery.min.js"></script>
<input type = "text" class = "foo" />
<input type = "text" class = "foo" />
<input type = "text" class = "foo" />

CSS

input{
	display: block;
}

JavaScript

$(".foo").on("keypress", function(event){
	var valor = String.fromCharCode(event.keyCode);
	if (isNaN(valor) && !isFinite(valor)){
		event.preventDefault();
		alert("Ingrese números");
	}
});