Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Radio button vs Textbox

Status
Not open for further replies.

Malchik

Programmer
Dec 8, 2001
148
CA
Hi

How can i validate a textbox based on a radio button. Let says I have two radio buttons in a form : Invoice Paper and E-Bill If the user select E-Bill I want to make sure the email textbox is not empty, otherwise it does not matter.

I need to do that on the submit button. I am working with DW CS4 and C#. I am use to work with VS2008 and VB.net... so i am relearning stuff here.

Thank you for your help

Mal'chik [bigglasses]
 
Here is what I tried:

Code:
<input name="optBill" type="radio" id="optBill" onmouseup="<%Contact_Email.Text = "YourEmailGoesHere"%>" value= "PAPER" <%if(AdorRec.FieldValue("Billing_Type", null)=="PAPER") {Response.Write("checked");}else{Response.Write("");}%> />Through Email (EBill)

The Idea is that if the user select EBill, the email textbox has to be set to enabled. For testing purposes, I temporally try to change the text property of the email textbox. When I try nothing happen

Mal'chik [bigglasses]
 
I changed how the validation would work. Instead I added a small javascript to validate the field when the submit button is use. Here is the code, in cas it can help someone:

Code:
<script language="JavaScript">
	function ValidateEmailForEBill()
	{
		if (document.getElementById("optBill2").checked)
			if (document.getElementById("Contact_Email").value=="" && document.getElementById("Customer_Email").value=="")
			{
				alert('Because the Paperless invoicing has been selected, you need to provide an Email address for either the Contact or the Company.');
				return false;
			}
			else
				return true;
		else
			return true;
	}
</script>

Mal'chik [bigglasses]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top