Hi all,
I am beginner in javascript. I am attempting to change border color and style of a asp.net text box using javascript. The function is inside a .js file. It is as follows.
function checkMoney(controlID)
{
var control = document.getElementById(controlID);
var text = control.value;
var letter;
if (text == "") // Avoid validating on onblur when user is still to enter anything
{
return false;
}
for(i=0;i<text.length;i++)
{
letter = text.charAt(i);
if(!(letter >="0" && letter <="9"))
{
if(letter == ".")
{ }
else
{
document.getElementById(controlID).focus();
document.getElementById(controlID).style.borderColor="red";
document.getElementById(controlID).style.borderStyle="solid";
alert("Enter only numbers");
return 0;
}
}
}
document.getElementById(controlID).style.borderStyle="";
return true;
}
When error is there, text box is highlighted properly. But when mistake is corrected, border color doesn't return to normal. Please help !