Hi all.
My first 3 if statements for Name, Department and Date execute correctly.
The 4th item is a radio button. I want to execute the WithoutContent function on the CPT4 code field only if the radio button for the NewEdit field has a specific value (New Charge Number).
The way I currently have the code, the WithoutContent function does execute for the CPT4 code field, but regardless of which value the NewEdit field has.
What am I missing? My code is below.
Thanks!!
- Valerie
<script type="text/javascript" language="JavaScript">
function CheckRequiredFields() {
var errormessage = new String();
// Put field checks below this point.
if(WithoutContent(document.chargeform.txtSubmitter.value))
{ errormessage += "\n\nPlease Enter Name."; }
if(WithoutContent(document.chargeform.txtDept.value))
{ errormessage += "\n\nPlease Enter Department."; }
if(WithoutContent(document.chargeform.txtDate.value))
{ errormessage += "\n\nPlease Enter Date."; }
if (document.chargeform.NewEdit.value = "New Charge Number") {
(WithoutContent(document.chargeform.txtCPT4Code.value))
{ errormessage += "\n\nPlease CPT4 Code.";}
}
// Put field checks above this point.
if(errormessage.length > 2) {
alert('NOTE:' + errormessage);
return false;
}
return true;
Hi. I'm going to post the entire page of code this time. I couldn't quite follow the last suggestion by Warren, although I thank you for your help. It looks like I didn't explain myself right the first time. Let me try again...
You will see that the NewEdit field has 2 radio buttons. What I'd like to have happen is when someone chooses New Charge Code radio button, the CPT4 Code text field will also be required. If the user chooses the Edit Charge Code button, then the CPT4 field code does not need to be checked.
Thanks again to all who are trying to make sense of all this for me.
I should also probably mention that there are some other files involved in the processing of the form, they format the e:mail and say where to send it. If anyone needs to see these, let me know.
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>Affinity Charge Request Form</title>
<!-- Beginning of JavaScript for checking required fields -->
<script type="text/javascript" language="JavaScript">
function CheckRequiredFields() {
var errormessage = new String();
// Put field checks below this point.
if(WithoutContent(document.chargeform.txtSubmitter.value))
{ errormessage += "\n\nPlease Enter Name."; }
if(WithoutContent(document.chargeform.txtDept.value))
{ errormessage += "\n\nPlease Enter Department."; }
if(WithoutContent(document.chargeform.txtDate.value))
{ errormessage += "\n\nPlease Enter Date."; }
if (document.chargeform.NewEdit.value == "New Charge Code") {
(WithoutContent(document.chargeform.txtCPT4Code.value))
{ errormessage += "\n\nPlease CPT4 Code.";}
}
// Put field checks above this point.
if(errormessage.length > 2) {
alert('NOTE:' + errormessage);
return false;
}
return true;
function WithoutSelectionValue(ss) {
for(var i = 0; i < ss.length; i++) {
if(ss[i].selected) {
if(ss[i].value.length) { return false; }
}
}
return true;
}
</script>
</head>
<body>
<form name="chargeform" method="post" onSubmit="return CheckRequiredFields()" action="http://hhs7/ChargeForm/simplemail.asp">
<!-- The start of the form shows that we are going to post the result back to the file 'simplemail.asp' -->
<h2 align="center">Affinity Charge Number Request Form:</h2>
<p><font color="red" size="+1">Items with * are required for form submission.</font></p>
</tr>
<tr>
<td>
If this is a change in an existing code, please state reason:
</td>
<td>
<textarea name="txtRemarks" cols=50 rows="5"></textarea>
</td>
</tr>
<tr>
<td colspan="2">
<p>
<input type="submit" value="Submit" />
<input type="reset" value="Clear Entry Fields" />
</p>
</form>
</td>
</tr>
<p>For questions about this form, call the Janice at extension 6502.</p>
</td>
</tr>
</table>
</body>
</html>
<form name="chargeform" method="post" onSubmit="return CheckRequiredFields()" action="http://hhs7/ChargeForm/simplemail.asp">
<!-- The start of the form shows that we are going to post the result back to the file 'simplemail.asp' -->
<h2 align="center">Affinity Charge Number Request Form:</h2>
<p><font color="red" size="+1">Items with * are required for form submission.</font></p>
<table border="1" width="100%">
<tr>
<td width="50%">
<font color="red">*</font> Submitter: <input type="text" name="txtSubmitter" size="25"><br>
<font color="red">*</font> Department: <input type="text" name="txtDept" size="25"><br>
<font color="red">*</font> Date Submitted: <input type="text" name="txtDate" size="25"><br>
</td>
<td width="50%">
Type of Request<br>
<input type="radio" name="NewEdit" value="New Charge Code">New Charge Number Needed<br>
<input type="radio" name="NewEdit" value="Edit Charge Code">Edit of Existing Charge Number
</td>
</tr>
<tr>
<td>
Charge Code (New or Exisiting):
</td>
<td>
<input type="text" name="txtChargeCode" maxlength="15" size="15" />
</td>
</tr>
<tr>
<td>
If this is a change in an existing code, please state reason:
</td>
<td>
<textarea name="txtRemarks" cols=50 rows="5"></textarea>
</td>
</tr>
<tr>
<td colspan="2">
<p>
<input type="submit" value="Submit" />
<input type="reset" value="Clear Entry Fields" />
</p>
</form>
</td>
</tr>
<p>For questions about this form, call the Janice at extension 6502.</p>
</td>
</tr>
</table>
</body>
</html>
The Silent One
The most dangerous thing in the world is an idea.
The most dangerous person in the world is one with an idea
Bookmarks