Rehola.
Código:
function EvaluateText(cadena, obj, e){
opc = false;
tecla = (document.all) ? e.keyCode : e.which;
if (cadena == "%d")
if (tecla > 47 && tecla < 58)
opc = true;
if (cadena == "%f"){
if (tecla > 47 && tecla < 58)
opc = true;
if (obj.value.search("[.*]") == -1 && obj.value.length != 0)
if (tecla == 46)
opc = true;
}
return opc;
}
<INPUT name="cp" type="text" class="texfield" size="10" onKeyPress="return EvaluateText('%f', this,event);">
Espero que te sirva. Saludos,