I am using a script for my textbox to make sure the user can enter only numbers instead of text.
Here is my textbox:
<input type="text" value="" id="tb1" name="tb1" onkeypress="return isNumber(event)" />
And here is my javascript:
function isNumber(evt) {
evt = (evt) ? evt : window.event;
var charCode = (evt.which) ? evt.which : evt.keyCode;
if (charCode > 31 && (charCode < 48 || charCode > 57)) {
return false;
}
return true;
}
I want to upgrade my JavaScript. I want that the textbox accepts a input with a dot .
(only 1 dot), like 11.5
What do I need to change in my script so it will be accept the dot and limit this to one?