Checkbox with mandatory textbox?
Posted on 2002-07-05
Please help me. I have a form that has a checkbox with an adjacent textbox. If a user checks the box, they must enter an email address in the textbox. (the form will not submit if the checkbox is checked and nothing is in the textbox, else the form submits as normal)
The form already has an onSubmit event that calls a basic existing validation script.
Here's the basics:
<form name="myForm" method="post" action="content_go.asp" onSubmit="return CheckForm();">
<input type="checkbox" name="chkAnon" value="Yes">
If checked, provide eMail:
<input type="text" name="txtAnonEmail" maxlength="50" size="20">
var myFormChk = window.document.myForm;
// Check the fields
.......form check stuff......
Thank you kindly.