i just need to validate one field, and make sure they input a title
do i put my html separate from my js, or all in teh same code box??
using this js
function validate_form ( )
{
valid = true;
if ( document.contact_form.recommendation.value == "" )
{
alert ( "Please fill in the 'Document Title' box." );
valid = false;
}
return valid;
}
<form name="contact_form" method="post"
action="/cgi-bin/articles/development/
javascript/form-validation-with-javascript/contact_simple.cgi"
onsubmit="return validate_form ( );">
<table cellspacing="0" cellpadding="0" style="margin-bottom: -10px;">
<tr>
<td><p>NAME:<span class="loud"></span> <br />
<INPUT NAME="name" value="<?=$name?>" TYPE="text">
</p></td>
</tr>
<tr>
<td><!-- -->
<p>E-MAIL:<span class="loud"> </span><br />
<INPUT NAME="email" value="<?=$email?>" TYPE="text">
</p></td>
</tr>
<tr>
<td><!-- -->
<p>DOCUMENT TITLE:<span class="loud"> *required</span><br />
<INPUT NAME="recommendation" value="<?=$document?>" TYPE="text">
</p></td>
</tr>
<tr>
<td><p>COMMENTS:<br />
<textarea name="comments" class="cmsg" wrap="on"><?=$comments?></textarea>
<!--<br /> -->
</p></td>
</tr>
</div>
<tr>
<td><p style="margin-top: -3px;">
<INPUT TYPE="submit" CLASS="submit" VALUE=" Submit ">
<!-- -->
<INPUT TYPE="reset"CLASS="submit" VALUE=" Clear ">
</td>
</tr>
<tr>
</p>
</td>
</tr>
</tr>
</td>
</table>
</FORM>
</div>
Post edited by: kade119, at: 2008/01/31 22:01<br><br>Post edited by: kade119, at: 2008/01/31 22:03