Estoy tratando de que se ejecute este error personalizado al teclear pero no me sale
window.onload = function(){
var cedula = document.getElementById('cedula');
cedula.oninput = Numeros;
}
function Numeros(){
var cedula = document.getElementByid('cedula');
alert("");
cedula.addEventListener('invalid', function(evt){
if(this.validity.patternMismatch)
{
alert(this.validity.patternMismatch)
this.setCustomValidity('solo numeros');
}
});
cedula.addEventListener('input', function(evt){
this.setCustomValidity('');
});
}
<!DOCTYPE html>
<html lang = "es">
<head>
<meta charset = "UTF-8">
<title>Formulario de registro</title>
<link rel="stylesheet" href="../css/reg.css">
<script src = "../js/jquery-3.2.1.min.js"></script>
<script src = "../js/validar1.js"></script>
</head>
<body>
<h1>Formulario de registro</h1>
<form method= "post" class = "form-registro">
<h2> Crear capitanes</h2>
<div class ="contenedor-input">
<input type = "text" pattern = "[0-9]" id = "cedula" name = "cedula" placeholder = "Cedula" class = "input-100" required>
<input type = "button" value = " Registrar capitan" class = "btn-enviar" id = "btn-enviar">
</div>
</form>
</body>
</html>
La verdad no se que se que estoy haciendo mal, agradezco su ayuda.