[x]
Posted via EE Mobile

Search, ask, and monitor your questions on the go with EE Mobile. Visit Experts Exchange from your mobile device and never be out of touch again.

Question
[x]
Attachment Details
[x]
The Solution Rating System

With so many solutions, how can you tell which solutions are most likely to help you and which ones are not? To provide you with a tool to use, we rate our solutions based on various elements that most accurately determine if a solution is a quality solution. To explain what factors affect the solution rating, here are the elements we take into consideration when formulating our solution rating.

  • The Grade of the Solution
  • The Zone Rank of the Expert Providing the Solution
  • The Number of Author and Expert Comments
  • The Number of Experts Contributing
  • The Feedback of the Community

Your Input Matters
Because of the way the system is set up, the most important variable in this equation is you. As a member of Experts Exchange, you are able to cast your vote on the quality of the solutions in regard to how complete, accurate, helpful and easy to understand each solution is. When you provide your feedback, each rating is adjusted accordingly. So, if you see a solution that has a poor rating that you think is a good solution, let us know by rating it. As you do, the rating will be adjusted and will become more accurate for other members of our site.

If you have any suggestions that you would like to make for our rating system, please ask a question in the Suggestions Zone of Community Support.

Thank you!

9.1

How Do I Validate a textbox (make sure it's not empty) when a checkbox is checked

Asked by aspnewbie09 in Programming for ASP.NET, Microsoft Visual Studio Express, JScript

Tags: Checkbox, Textbox, Javascript, ASP.net, Visual Web Developer 2008

I have been looking for several hours trying to find code for requiring a customer to enter qty in the qty_field when a checkbox is checked.  Here's what I am trying to do:

i have several test available, so when customers checked on Checkbox1(or Checkbox2); they must also enter a qty for the qty_field.  The qty_field is used for calculation later.  I try ASP.net 2.0 Validation, but it does not have option for me to tell it that if checkbox1 is checked, then qty1 must also cannot be empty. I am storing my values using session.  what i have below does not work (and no error message), just no result.  

How do I validate the checkbox and the textbox before submitting the form?

thanks


my aspx code:
<form id="form2" runat="server">
<div>
<table cellpadding="4" cellspacing="0" width="100%" border="1">
         <tr>
       <td width="40%">
      <asp:CheckBox ID="CheckBoxLT1" Text="Test1" runat="server" />
          </td>
      <td width="10%">
      <asp:TextBox ID="txtltNumTest" runat="server" Width="70px"></asp:TextBox>
    </td>
</tr>
<tr> <td width="40%"><asp:CheckBox ID="CheckBoxLT2" Text="Test2" runat="server" />
 </td>   <td width="10%"><asp:TextBox ID="txtltNumTest2" runat="server" style="height: 22px"
 Width="70px"></asp:TextBox>
</td> </tr>
</table>
<asp:Button ID="Button1" runat="server" Text="Submit" />
</div>
</form>


aspx.vb code:

Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click

 'check to see which test is checked
       'check to see which test is checked
        If CheckBox1.Checked = True Then
            If AntiNumTest.Text <> "" Then
                Session("testqty") = CInt(AntiNumTest.Text)
                Session("anticost") = Session("testqty") * 250
            Else
                response.write ("Please Enter qty for test")
            End If
        End If

Session("Cost") = Session("anticost")
Response.Redirect("page2.aspx")

End Sub



[+][-]11/03/09 02:47 PM, ID: 25734730Accepted Solution

View this solution now by starting your 30-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

About this solution

Zones: Programming for ASP.NET, Microsoft Visual Studio Express, JScript
Tags: Checkbox, Textbox, Javascript, ASP.net, Visual Web Developer 2008
Sign Up Now!
Solution Provided By: Psyberion
Participating Experts: 3
Solution Grade: A
 
[+][-]11/03/09 02:04 PM, ID: 25734299Expert Comment

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]11/03/09 02:06 PM, ID: 25734330Expert Comment

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]11/03/09 02:11 PM, ID: 25734388Expert Comment

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
 
Loading Advertisement...
20091111-EE-VQP-92 - Hierarchy / EE_QW_3_20080625