i am applying validate the text with value it may be positive whole number
or number with one decimal point
i am applying validate the text with value it may be positive whole number
or number with one decimal point in javascript 123 1 12345 233.2 1212.2
1.1 are valid number and 1.222 1.33 -89789 -3 are invalid number could you
help me please i have applied this but not get desired result
function CheckOneDecimal(txtbox) {
if (txtbox.value.length > 0)
{
if (isNaN(txtbox.value)) {
txtbox.value = "";
alert("Please enter number with one decimal places");
txtbox.focus();
return;
}
else if (parseFloat(txtbox.value) > 0)
{
txtbox.value = "";
alert("Please enter number with one decimal places.
eg. 8.1");
txtbox.focus();
return;
}
var oRegExp = /^\s*\d+\.\d{1}\s*$/;
if (oRegExp.test(txtbox.value))
{ }
else {
txtbox.value = "";
alert("Please enter number with one decimal
places");
txtbox.focus();
}
}
}
Thanks in advance
No comments:
Post a Comment