Question: I am trying to validate a form without displaying the error message as an alert. innerHTML seems to be my best bet.

I have tried to implement it but I'm having no luck.

Here is the code.

Javascript:

```
    <script> function validateForm() {
            var x = "";
            if (document.orderForm.firstName.value = "")
            x += "Please enter your first name.";
            document.getElementById('error').innerHTML = x;
            return false;
            }</script>

```

HTML:

```
     <form name="orderForm" method="post" onsubmit="return validateForm()" action="processForm.html" >
    <table>
        <tr>
            <th colspan="2">Personal Information</th>
        </tr>
        <tr>
            <td>First Name:</td>
            <td><input type="text" name="firstName" id="firstName" size="30"></td>

        </tr>
        </table>
    <div name="error" id="error"> 
    </div>
   </form>

```

Right now no error message is displayed.

Answer: 
```
<script> function validateForm() {
        if (document.orderForm.firstName.value == ""){ // == is comparison... = is assignment
            document.getElementById('error').innerHTML = "Please enter your first name.";
            return false;
        }
        else
            return true //Don't forget to return true if everything checks out
        }</script>

```
`if (document.orderForm.firstName.value = "")` **assigns** the value `""` to `document.orderForm.firstName.value`, then evaluates as a *false* value, so the `if` statement will never be true.

Use a comparison, not an assignment. `==`.

---

While you are at it, please learn about [validators](http://validator.w3.org), [labels](http://www.456bereastreet.com/archive/200711/use_the_label_element_to_make_your_html_forms_accessible), and [CSS](https://www.hotdesign.com/seybold/).