Suggestion 1: Put ID attributes in the tags so you can access them easier
Suggestion 2: Make the onsubmit attribute be onsubmit="return validate()"
Suggestion 3: getElementByClassName doesn't exist. getElementsByClassName returns an array, so you have to pick which one, or loop through them. IE, document.getElementsByClassName('t1')[0]
Suggestion 4: Your validate function needs to return false if you want the form to not submit, and true if it should submit.
Javascript:
function validate () {
if( document.getElementById("firstname").value == "" || document.getElementById("firstname").value == null )
{
document.getElementsByClassName('t1')[0].setAttribute('style','display: inline;');
return false;
}
return true;
}
HTML:
<form name="quote" method="post" action="" onSubmit="return validate()">
<fieldset>
<legend>Contact Information</legend>
<div>
<label>*First Name:</label><span class="t1">Please enter your name</span>
<input id="firstname" name="firstname" type="text"/>
</div>
</fieldset>
<div id="f-submit">
<input name="Submit" value="Submit" type="submit"/>
</div>
</form>