Hi,
You can try this one.
function Validate() {
var o = document.getElementById("valueCent");
var val = o.value;
if (val.length == 0) {
alert("Please Enter Value");
return;
}
var index = val.search(/[^0-9\.]/);
if (index != -1) {
o.selectionStart = o.selectionEnd = index;
alert("Invalid Characters");
return;
}
if (val.match(/\./g).length > 1)
{
alert("Invalid Number");
return;
}
var floatVal = parseFloat(val);
if (floatVal < 0 || floatVal > 100)
{
alert("Value must be between 0.00 and 100.00");
return;
}
alert("Valid value of: " + floatVal.toFixed(2));
}
And to your HTML
<input id="valueCent" type="text" size="20">
<input type="button" value="Check" önclick="Validate()">