Hi,
I'm trying to validate the date. First I want to strip out non digit charater. If the non digit char. is not "/", then I want to pop the alert box. It seem that the statement that I compare with "/" is not working. When I enter date as 05/01/06 (with slash), the alert box pop up.
thanks in advance
I'm trying to validate the date. First I want to strip out non digit charater. If the non digit char. is not "/", then I want to pop the alert box. It seem that the statement that I compare with "/" is not working. When I enter date as 05/01/06 (with slash), the alert box pop up.
thanks in advance
Code:
for (i = 0; i < DateValue.length; i++)
{
if (checkstr.indexOf(DateValue.substr(i,1)) >= 0)
{
DateTemp = DateTemp + DateValue.substr(i,1);
}
[COLOR=red] else if (checkstr.indexOf(DateValue.substr(i,1)) != "/") [/color]
{
alert("Date is incorrect. Use mm/dd/yy format.");
DateField.focus();
return false;
}
}