I have this javascript validation code that I want to be able to clear an input text box when the inputed value is invalid.
Note: this is a reusable validation code.
Replies are very much appreciated. Thanks.
Note: this is a reusable validation code.
Code:
function isChar(form1)
{
var letters = "ABCDEFGHIJKLMNÑOPQRSTUVWXYZabcdefghijklmnñopqrstuvwxyz";
var strChar;
var dig = true;
if (form1.length == 0) return false;
for (a = 0; a < form1.length && dig == true; a++)
{
strChar = form1.charAt(a);
if (letters.indexOf(strChar) == -1)
{
dig=false;
alert("Invalid Input! Try Again.");
this.focus();
}
return dig;
}
}
Comment