How can I remove/disallow entering a dot . on my textbox?
Bind an event to your input tag
<input type="text" onkeypress="return preventDot(event);" />
Then create a function like preventDot that will return false and prevent the key from being entered if the . key is pressed
function preventDot(e)
{
var key = e.charCode ? e.charCode : e.keyCode;
if (key == 46)
{
return false;
}
}
http://jsfiddle.net/Bf6Xq/6/
Is this what you mean?
JavaScript:
function preventDot(id)
{
str = document.getElementById(id).value;
document.getElementById(id).value = (str.replace(".",""));
}
HTML:
<input type="text" id="input" onkeyup="preventDot(this.id)" />
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With