hey all just a quick question.
i'm creating a very simple validation for 3 input fields, name, email and a text area. i figured out the first 2 but i cant get the text area to work.
any thoughts?
this is the javascript code:
=========================================
this is the html:
i'm creating a very simple validation for 3 input fields, name, email and a text area. i figured out the first 2 but i cant get the text area to work.
any thoughts?
this is the javascript code:
Code:
<script type="text/javascript">
function validateForm()
{
var x=document.forms["myForm"]["Full_Name"].value
if (x==null || x=="")
{
alert("Full Name must be filled out");
return false;
}
var x=document.forms["myForm"]["Email"].value
var atpos=x.indexOf("@");
var dotpos=x.lastIndexOf(".");
if (atpos<1 || dotpos<atpos+2 || dotpos+2>=x.length)
{
alert("Not a valid e-mail address");
return false;
}
var x=document.forms["myForm"]["Comments_Questions"].value
if (x==null || x=="")
{
alert("Please leave a comment.");
return false;
}
}
</script>
=========================================
this is the html:
Code:
<form name="myForm" onsubmit="return validateForm()" action="formmail.php" method="post">
<div class="row"><label class="col1">Full Name: </label>
<span class="col2">
<input name="Full_Name" class="input" type="text" id="First Name" size="20" tabindex="1" />
</span></div>
<br />
<br />
<br />
<div class="row"><label class="col1">Email: </label>
<span class="col2">
<input name="Email" class="input" type="text" id="Email" size="20" tabindex="2" />
</span></div>
<br />
<br />
<br />
<div class="row"><label class="col1">Comments: <br />Questions </label>
<span class="col2">
<textarea name="Comments_Questions" class="input" type="text" id="comments" cols="18" rows="5" tabindex="2" />
</textarea>
</span></div>
<div id="formbuttonsContainer">
<input type="submit" class="submitButton"/>
</div>
</form>