I have a simple html form and i have a small piece of script which validates it,
I would like it so that after the validation is carried out, if the return value is true, then the user will be redirected to index.html
i have tried several pieces of code to the end of my validation script but i cant get the page to change
Any help would be appreciated
Here is my javascript code
function validate_form ( )
{
var illegalChars= /[\(\)\<\>\,\;\:\\\/\"\[\]]/;
valid = true;
if ( document.contactform.firstname.value == "" )
{
document.contactform.firstname.style.background= 'Yellow';
alert ( "Please fill in the 'First Name' box." );
valid = false;
}
if ( document.contactform.lastname.value == 0 )
{
document.contactform.lastname.style.background= 'Yellow';
alert ( "Please fill in the 'Last Name' box." );
valid = false;
}
if (document.contactform.email.value.match(illegalChars))
{
document.contactform.email.style.background= 'Yellow';
alert ( "Illegal Characters" );
valid = false;
}
if ( document.contactform.email.value == 0 )
{
document.contactform.email.style.background= 'Yellow';
alert ( "Please fill in the 'Email' box." );
valid = false;
}
if ( document.contactform.message.value == 0 )
{
document.contactform.message.style.background= 'Yellow';
alert ( "Please fill in the 'Message' box." );
valid = false;
}
return valid;
}