PDA

View Full Version : How can I to control characters in an input text?



osvaldogomez
03-03-2008, 05:28 PM
Hi,

I'm don't want the character ',' be print in the input text box, but I can do it work. Here is the code

function fieldNumber(objeto, e){

if(window.event && e.keyCode == 188){ // this is the keycode for IE & Firefox
keynum=e.keyCode;
e.keyCode=0;
return false;
}else if(e.which =44){// this is the opera's keycode
e.which = 0;
return false;
}

return true;
}

<input type="text" name="pepe" onkeydown=" return fieldNumber(this, event)" />

Could someone help me please?

Any help is welcome.-

Regards

Master_script_maker
03-03-2008, 08:35 PM
<script type="text/javascript">
function remove(o) {
var i=document.getElementById(o.id);
i.value=i.value.substring(0,i.length-1);
}
function fieldNumber(o, e){
if(window.event && e.keyCode == 188){ // this is the keycode for IE & Firefox
keynum=e.keyCode;
e.keyCode=0;
remove(o);
}else if(e.which =44){// this is the opera's keycode
e.which = 0;
remove(o)
}
return false;
}
</script>

<input type="text" name="pepe" id="pepe" onkeydown="fieldNumber(this, event)" />