Here is what I want to happen.
If someone checks the box that they want to participate on the committee (bottom of form), AND either the Name OR Phone are blank, then display the error when they click submit.
Thank you!!
Here is the snippet of just this line of Javascript...
Here is the entire form...
Thank you again.
If someone checks the box that they want to participate on the committee (bottom of form), AND either the Name OR Phone are blank, then display the error when they click submit.
Thank you!!
Here is the snippet of just this line of Javascript...
Code:
[COLOR=red]if (document.HRSurvey.participate.checked && document.HRSurvey.names.value=="" || document.HRSurvey.phone.value=="")
{
errormessage += " Please provide your name and phone to receive information about the Benefits Council, or uncheck the box.\n";
}
[/color]
Here is the entire form...
Code:
<html><head>
<title>Employee Survey</title>
<!-- Beginning of JavaScript for checking required fields -->
<script type="text/javascript" language="JavaScript">
<!--
function CheckRequiredFields() {
errormessage = "Please answer the following:\n";
if (radioNotChecked(document.HRSurvey.easy))
{
errormessage += " The HR page is easy to understand and navigate.\n";
}
if (radioNotChecked(document.HRSurvey.locateinfo))
{
errormessage += " I was able to locate information quickly.\n";
}
if (radioNotChecked(document.HRSurvey.titles))
{
errormessage += " The document titles are easy to understand.\n";
}
if (radioNotChecked(document.HRSurvey.resource))
{
errormessage += " It is a good resource for employees and managers.\n";
}
if (radioNotChecked(document.HRSurvey.use))
{
errormessage += " I will use the HR Page regularly.\n";
}
[b]
if (document.HRSurvey.participate.checked && document.HRSurvey.names.value=="" || document.HRSurvey.phone.value=="")
{
errormessage += " Please provide your name and phone to receive information about the Benefits Council, or uncheck the box.\n";
}
[/b]
function noenter() {
return !(window.event && window.event.keyCode == 13); }
function radioNotChecked(grp) {
var i, len = grp.length;
for(i=0; i<len; i++) {
if(grp[i].checked) return false;
}
return true;
}
if(errormessage.length > 30){
alert(errormessage);
return false;
}
else{
return true;
}
}
//-->
</script>
</head>
<body>
<form name="HRSurvey" method="post" onSubmit="return CheckRequiredFields()" action="xt_email.asp">
<table cellspacing="2" cellpadding="6" border="1" width="100%">
<tr>
<td colspan="2">
<h2 align="center">Tell us what you think about the HR Benefits Page</h2>
<table cellpadding="8" border="1" width="100%">
<tr><td colspan="2">
<h4>We value your thoughts and opinions.<br/><br/>
<em>Instructions:</em> The survey items below are to be answered using the number associated with the choice that comes closest to your own feelings.<br/><br/>
You may submit this form anonymously.
</h4>
</td></tr>
</table>
</td>
</tr>
<tr bgcolor="#c0c0c0">
<td colspan="2">
1=Strongly Disagree 2=Disagree 3=Neither Agree Nor Disagree 4=Agree 5=Strongly Agree
</td>
</tr>
<tr bgcolor="#99CCFF">
<td width="50%">
<strong>The HR page is easy to understand and navigate.</strong></td>
<td width="50%" valign="middle">
<input type="radio" name="easy" value="Strongly Disagree" />1
<input type="radio" name="easy" value="Disagree" />2
<input type="radio" name="easy" value="Neither Agree Nor Disagree" />3
<input type="radio" name="easy" value="Agree" />4
<input type="radio" name="easy" value="Strongly Agree" />5
<br/><br/>
</td>
</tr>
<tr bgcolor="#c0c0c0">
<td width="50%">
<strong>I was able to locate information quickly.</strong></td>
<td width="50%"><input type="radio" name="locateinfo" value="Strongly Disagree" />1
<input type="radio" name="locateinfo" value="Disagree" />2
<input type="radio" name="locateinfo" value="Neither Agree Nor Disagree" />3
<input type="radio" name="locateinfo" value="Agree" />4
<input type="radio" name="locateinfo" value="Strongly Agree" />5
<br/><br/>
</td>
</tr>
<tr bgcolor="#99CCFF">
<td width="50%">
<strong>The document titles are easy to understand.</strong></td>
<td width="50%"><input type="radio" name="titles" value="Strongly Disagree" />1
<input type="radio" name="titles" value="Disagree" />2
<input type="radio" name="titles" value="Neither Agree Nor Disagree" />3
<input type="radio" name="titles" value="Agree" />4
<input type="radio" name="titles" value="Strongly Agree" />5
<br/><br/>
</td>
</tr>
<tr bgcolor="#c0c0c0">
<td width="50%">
<strong>It is a good resource for employees and managers.</strong></td>
<td width="50%"><input type="radio" name="resource" value="Strongly Disagree" />1
<input type="radio" name="resource" value="Disagree" />2
<input type="radio" name="resource" value="Neither Agree Nor Disagree" />3
<input type="radio" name="resource" value="Agree" />4
<input type="radio" name="resource" value="Strongly Agree" />5
<br/><br/>
</td>
</tr>
<tr bgcolor="#99CCFF">
<td width="50%">
<strong>I will use the HR Benefits Page regularly.</strong></td>
<td width="50%"><input type="radio" name="use" value="Strongly Disagree" />1
<input type="radio" name="use" value="Disagree" />2
<input type="radio" name="use" value="Neither Agree Nor Disagree" />3
<input type="radio" name="use" value="Agree" />4
<input type="radio" name="use" value="Strongly Agree" />5
<br/><br/>
</td>
</tr>
<tr bgcolor="#c0c0c0">
<td colspan="2">
<strong>Please share your comments and suggestions regarding HHS' new benefits page:</strong><br/>
<textarea cols="75" rows="3" name="comments" onkeypress="return noenter()" ></textarea>
<br/><br/>
</td>
</tr>
<tr><td colspan="2">
<h4>At this time HR is creating a team of employees to provide feedback and suggestions regarding current and future benefit programs offered at HHS. Would you be interested in participating on this team?<br/><br/>
[b]<input type="Checkbox" name="participate" /> Yes, please contact me about participating on the Benefits Council.
</h4>
[/b]
<strong>Name:</strong>
<input type="text" size="40" name="names" onkeypress="return noenter()" />
<strong>Phone:</strong>
<input type="text" size="15" name="phone" onkeypress="return noenter()" />
</td>
</tr>
<tr align="center" bgcolor="#c0c0c0">
<td colspan="2">
<input type="submit" value="submit" /> <input type="reset" value="clear" />
</td> </tr>
</table></form>
</body>
</html>
Thank you again.