function emptyvalidation(entered, alertbox)
{
    with (entered)
    {
        if (value==null || value=="")
        {
            if (alertbox!="")
            {
                alert(alertbox);
            }
            
            return false;
        }
        else
        {
            return true;
        }
    }
}

function emailvalidation(entered, alertbox)
{
    with (entered)
    {
        apos= value.indexOf("@");
        dotpos=value.lastIndexOf(".");
        lastpos=value.length-1;
        if (apos<1 || dotpos-apos<2 || lastpos-dotpos>3 || lastpos-dotpos<2)
        {
            if (alertbox) {alert(alertbox);} return false;
        }
        else
        {
            return true;
        }
    }
}

function formvalidation(thisform)
{
    with (thisform)
    {
		if (emptyvalidation(firstname, "Please enter your first name.")==false) {firstname.focus(); return false;};
		if (emptyvalidation(lastname, "Please enter your last name.")==false) {lastname.focus(); return false;};
		if (emptyvalidation(phone, "Please enter your phone number.")==false) {phone.focus(); return false;};
		if (emptyvalidation(postcode, "Please enter your postcode.")==false) {postcode.focus(); return false;};
    }
}