How to display multiple error messages on the same page using JavaScript
<p>I am working on java script and i am stuck on one phase. In my project i have to validate all fields when the form is submitted and display error message on same page in order list above the form field.  bellow is my code</p>

<pre><code>function validation(){
    var errorMsg=new Array(); 
    //var errorMsg = "";
    if(document.getElementById("fullname").value = " "){
        errorMsg[0] = "Please Enter Full Name\n"
}
if(document.getElementById("street").value = " "){
        errorMsg[1]= "Please Enter Street Name\n"
}
if(document.getElementById("postcode").value = " "){
        errorMsg[2]= "Please Enter Postlecode\n"
}
if(document.getElementById("phone").value = " "){
        errorMsg[3]= "Please Enter Phone Number\n"
}
if(document.getElementById("email").value = " "){
        errorMsg[4]= "Please Enter Email Id\n"
}
if(errorMsg!=" "){
    var r =" ";
    for(var i=0;i&lt;=errorMsg.length-1;i++){
    document.getElementById("error").innerHTML="&lt;li&gt;"+errorMsg[i]+"&lt;/li&gt;"
    }   
    return false;
}
}
&lt;/script&gt;
</code></pre>

<p>when i run this code it gives me only last value </p>

<p>can anybody help me how to display error message on the top of the form?</p>
