code in tags ...
function val2()
{
var regVal;
regVal= new RegExp("^[1-366]$");
if (!regVal.test(document.f1.duration.value))
{
alert('Please enter a duration between 1 and 366 days');
document.write (regVal.test(document.f1.duration.value));
//pls note the above line prints the result of the match to the screen . Every time the alert text says the match was false it really was false, not just a misfire of the alert text.
}
}