# Creating a form in Dreamweaver - required fields



## frosty71384 (Mar 3, 2005)

Hi, I have created a functional form in Dreamweaver. However, I can't seem to get the javascript to work so that people are required to fill in certain fields before the "submit" button works. The user can press submit with all blank fields and it still takes them to the next page. 

I know in Dreamweaver you can typically go to validate form and make the fields required, but it's not letting me do that because it's saying that my textfields are "unnamed"...(but they ARE named).... for example one of my fields is this:

<input name="Zip" type="text" id="Zip" size="35"></td> - the text field is zip right??

I know there is a way to manually code this...but looking at what someone else did, and trying to duplicate it isn't working either
i put 

onSubmit="return validateForm()"> 

into the line of code where the form begins and 

function validateForm()
{
formObj = document.form1;
if (formObj.zip.value == "")
{
alert("You have not filled in your Zip");
formObj.zip.focus();
return false;
}



}
under the javascript on the top of the page


not really sure how I can show someone what it looks like, maybe if i copy the html code?

thanks so much! any help is greatly appreciated!


Lisa


----------



## KoosHopeloos (Nov 3, 2004)

@ frosty71384: I think that you need to put a label to each of your form elements... e.g:


```
<tr> 
<td width="100"><font color="#000000" size="2" face="Verdana, Tahoma, Arial">
[B]<label for="Question2_Yes">[/B] 
<input type="radio" name="Question2_Yes" value="Yes" />Yes</label>
</font></td>
</tr>
<tr> 
<td width="100"><font color="#000000" size="2" face="Verdana, Tahoma, Arial">
[B]<label for="Question2_No">[/B] 
<input type="radio" name="Question2_No" value="No" />No</label>
</font></td>
</tr>
```
Hope this helps! Let me know...


----------

