Hola vito_gris!
Te he hecho esto, nno sé si te servirá. Respect oa comprobar si son número no te lo he hecho porque dices uqe eso lo puedes hacer.Si en cualquier caso no puedes unir los dos scripts me lo dices y lo miramos.
Un abrazo!
Código PHP:
<html>
<head>
<title>Textito</title>
<script>
function comprobar(esto){
if (esto.length==2){document.forms[0].texto.value+="-"}
if ((esto.length>2) && (esto.charAt(3)!="-")){
testo=esto.substring(0,2)+"-"+esto.substring(2,4);
}
}</script>
</head>
<body>
<form style="color: black; font: normal 10px/10px verdana;">
Código:<input type="text"
name="texto"
size="5"
maxlength="5"
style="border: solid 1px black; color: black; font: normal 10px/10px verdana;"
onkeydown=comprobar(this.value)>
</form>
</body>
</html>