lbeddawi 0 Newbie Poster

Hi everyone;

I'm pretty new to VB.NET and I'd like your help in validating the CheckBoxList because I have two of them and then how to read them with an attachment file.

Appreciate the help:

here is the code

<%@ Page Language="VB" AutoEventWireup="true" CodeFile="test.aspx.vb" Inherits="test" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.4/jquery.min.js" 
    type="text/javascript"></script>
       <script type="text/javascript">

           $(function () {
               $('#<%= Submit.ClientID %>').click(function () {

                   var checkedControls = $('#<%= days_of_week.ClientID %>').find('input:checkbox:checked');

                   if (checkedControls.length > 0) {
                       alert('Valid');
                   }
                   else {
                       alert('Please select atleast one checkbox');
                   }
                   return false;
               });
           }); 
    
    </script>
  
    
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title>Internship Form</title>
                    
</head>
<body>
    <form id="form1" runat="server">
    <div>
   	      <table align="left" width="75%">
<tr>
<td align="right"  dir="ltr" valign="middle" class="style6">
<asp:Label ID="Firstname_label" 
        runat="server" Text="* First Name:" AssociatedControlID="FirstName" 
        align="left" Font-Bold="True" Font-Strikeout="False"></asp:Label>
    </td>
<td valign="baseline" align="left" class="style2">

<asp:TextBox 
        ID="FirstName" runat="server" Height="20px" Width="117px" 
         AutoPostBack="True" CausesValidation="True" 
        MaxLength="30"></asp:TextBox>
<TD>
    <asp:RequiredFieldValidator runat="server"
      id="reqName" ControlToValidate="FirstName"
      ErrorMessage = "You must provide your first name!"
      display="Dynamic" />
      <asp:RegularExpressionValidator ID="regexpFirstName" runat="server"     
                                    ErrorMessage="This expression does not validate." 
                                    ControlToValidate="FirstName"     
                                    ValidationExpression="^[a-zA-Z'.\s]{1,40}$"
                                    display="dynamic" />
</TD>
</td>
 
</tr>

<tr>
<td valign="middle" align="right" class="style6">
<asp:Label ID="lastname_label" 
        runat="server" Text="* Last Name:" AssociatedControlID="lastname" 
        align="left" Font-Bold="True" Font-Strikeout="False"></asp:Label></td>
<td valign="top" align="left" class="style2">
<asp:TextBox 
        ID="lastname" runat="server" Height="20px" Width="117px" 
         AutoPostBack="True" CausesValidation="True" 
        MaxLength="30"></asp:TextBox>


<TD>
    <asp:RequiredFieldValidator runat="server"
      id="reqLastName" ControlToValidate="lastname"
      ErrorMessage = "You must provide your last name!"
      display="Dynamic" />
  </TD>
</tr>
<tr>
<td valign="middle" align="right" class="style6">
<asp:Label ID="Address_label" 
        runat="server" Text="Address:" AssociatedControlID="StreetAddr" 
        align="left" Font-Bold="True" Font-Strikeout="False"></asp:Label></td>
<td valign="top" align="left" class="style2">
<asp:TextBox 
        ID="StreetAddr" runat="server" Height="20px" Width="117px" 
         AutoPostBack="True" CausesValidation="True" 
        MaxLength="40"></asp:TextBox>


<td><asp:RegularExpressionValidator runat="server"
      id="regexpaddress" ControlToValidate="StreetAddr"
      ErrorMessage = "Your address must be four digits only."
      ValidationExpression="^\d{1,4}$"
      Display="Dynamic" />
      </td>
     
</tr>

<tr>
<td valign="middle" align="right" class="style6">
<asp:Label ID="Address2_label" 
        runat="server" Text="Address Line 2 (optional):" AssociatedControlID="StreetAddr2" 
        align="left" Font-Bold="True" Font-Strikeout="False"></asp:Label>
</td>
<td valign="top" align="left" class="style2">
<asp:TextBox 
        ID="StreetAddr2" runat="server" Height="20px" Width="117px" 
         AutoPostBack="True" CausesValidation="True" 
        MaxLength="40"></asp:TextBox>
</td>

<td>

</td>
</tr>

            
<tr>
<td valign="middle" align="right" class="style6" >
<asp:Label ID="citylabel" 
        runat="server" Text="City:" AssociatedControlID="City" 
        align="left" Font-Bold="True" Font-Strikeout="False"></asp:Label>

</td>
<td valign="top" align="left" class="style2">
<asp:TextBox 
        ID="City" runat="server" Height="20px" Width="117px" 
         AutoPostBack="True" CausesValidation="True" 
        MaxLength="30"></asp:TextBox>
    </td>

    <td>
    <asp:RegularExpressionValidator runat="server"
      id="regexpCity" ControlToValidate="City"
      ErrorMessage = "Your must enter characters only."
      ValidationExpression="^[a-zA-Z'.\s]{1,40}$"
      Display="Dynamic" />
    </td>
</tr>

<tr>
<td valign="middle" align="right" class="style3">
<asp:Label ID="statelabel" 
        runat="server" Text="State:" AssociatedControlID="state" 
        align="left" Font-Bold="True" Font-Strikeout="False"></asp:Label>
</td>

<td valign="top" align="left" class="style4">
<asp:TextBox 
        ID="state" runat="server" Height="20px" Width="20px" 
         AutoPostBack="True" CausesValidation="True" 
        MaxLength="2"></asp:TextBox>

</td>
<td><asp:RegularExpressionValidator runat="server"
      id="regexpstate" ControlToValidate="state"
      ErrorMessage = "Your state should be two charecters only."
      ValidationExpression="^\d{1,2}$"
      Display="Dynamic" />
      </td>
</tr>
            
<tr>
<td valign="middle" align="right" class="style6">

<asp:Label ID="ziplabel" 
        runat="server" Text="Zip:" AssociatedControlID="postalCode" 
        align="left" Font-Bold="True" Font-Strikeout="False"></asp:Label>
<td valign="top" align="left" class="style2">
<asp:TextBox 
        ID="postalCode" runat="server" Height="20px" Width="50px" 
         AutoPostBack="True" CausesValidation="True" 
        MaxLength="5"></asp:TextBox>

</td>
<td><asp:RegularExpressionValidator runat="server"
      id="regexppostalCode" ControlToValidate="postalCode"
      ErrorMessage = "Your zip code must be five digits."
      ValidationExpression="^\d{1,5}$"
      Display="Dynamic" />
      </td>
</tr>

<tr>
<td valign="middle" align="right" class="style6">
<asp:Label ID="dayphonelabel" 
        runat="server" Text="Daytime/Work Phone: (000) 000-0000:" AssociatedControlID="Day_Phone" 
        align="left" Font-Bold="True" Font-Strikeout="False"></asp:Label>


</td>
<td valign="top" align="left" class="style2">
<asp:TextBox 
        ID="Day_Phone" runat="server" Height="20px" Width="117px" 
         AutoPostBack="True" CausesValidation="True" 
        MaxLength="10"></asp:TextBox>


        <td>
        <asp:RegularExpressionValidator runat="server"
      id="regexpDay_Phone" ControlToValidate="Day_Phone"
      ErrorMessage = "Your phone number does not match schema."
      ValidationExpression="^[01]?[- .]?(\([2-9]\d{2}\)|[2-9]\d{2})[- .]?\d{3}[- .]?\d{4}$"
      Display="Dynamic" />
        
        </td>
        
        </td>
</tr>

<tr>
<td valign="middle" align="right" class="style6">
    <asp:Label ID="Eveningphonelabel" 
        runat="server" Text="Evening Phone: (000) 000-0000:" AssociatedControlID="Evening_Phone" 
        align="left" Font-Bold="True" Font-Strikeout="False"></asp:Label></td>
<td valign="top" align="left">
<asp:TextBox 
        ID="Evening_Phone" runat="server" Height="20px" Width="117px" 
         AutoPostBack="True" CausesValidation="True" 
        MaxLength="10"></asp:TextBox>

</td>
<td>
<asp:RegularExpressionValidator runat="server"
      id="regexpEvening_Phone" ControlToValidate="Evening_Phone"
      ErrorMessage = "Your phone number does not match schema."
      ValidationExpression="^[01]?[- .]?(\([2-9]\d{2}\)|[2-9]\d{2})[- .]?\d{3}[- .]?\d{4}$"
      Display="Dynamic" />
</td>
</tr>

<tr>
<td valign="middle" align="right" class="style6">
<asp:Label ID="email_label" 
        runat="server" Text="* Email:" AssociatedControlID="EmailAddr" 
        align="left" Font-Bold="True" Font-Strikeout="False"></asp:Label>



</td>
<td valign="top" align="left">
<asp:TextBox 
        ID="EmailAddr" runat="server" Height="20px" Width="117px" 
         AutoPostBack="True" CausesValidation="True" 
        MaxLength="40"></asp:TextBox>

<TD>
    <ASP:RequiredFieldValidator runat="server"
      id="reqEmailAddr" ControlToValidate="EmailAddr"
      ErrorMessage = "You must provide your email!"
      display="Dynamic" />
  </TD></td>
</tr>



<tr>
<td valign="middle" align="right" class="style6">

<asp:Label ID="School_Name_label" 
        runat="server" Text="Name of School:" AssociatedControlID="School_Name" 
        align="left" Font-Bold="True" Font-Strikeout="False"></asp:Label>

</td>
<td valign="top" align="left" >
<asp:TextBox 
        ID="School_Name" runat="server" Height="20px" Width="117px" 
         AutoPostBack="True" CausesValidation="True" 
        MaxLength="30"></asp:TextBox>

</td>
<td>
<asp:RegularExpressionValidator ID="regexpSchool_Name" runat="server"     
                                    ErrorMessage="This expression does not validate." 
                                    ControlToValidate="School_Name"     
                                    ValidationExpression="^[a-zA-Z'.\s]{1,40}$" 
                                     display="dynamic"/>
</td>
</tr>

<tr>
<td valign="middle" align="right" class="style6">

<asp:Label ID="School_Years_label" 
        runat="server" Text="Year in School:" AssociatedControlID="School_Year" 
        align="left" Font-Bold="True" Font-Strikeout="False"></asp:Label>

</td>
<td valign="top" align="left" >
<asp:TextBox 
        ID="School_Year" runat="server" Height="20px" Width="50px" 
         AutoPostBack="True" CausesValidation="True" 
        MaxLength="4"></asp:TextBox>

</td>
<td>
<asp:RegularExpressionValidator ID="regexpSchool_Year" runat="server"     
                                    ErrorMessage="This expression does not validate." 
                                    ControlToValidate="School_Year"     
                                    ValidationExpression="^[0-9]{1}$" 
                                     display="dynamic" />

</td>

</tr>


<tr>
<td valign="middle" align="right" class="style6">
<asp:Label ID="Graduated_label" 
        runat="server" Text="Graduated:" AssociatedControlID="Graduated" 
        align="left" Font-Bold="True" Font-Strikeout="False"></asp:Label>



</td>
<td valign="top" align="left">

<asp:TextBox 
        ID="Graduated" runat="server" Height="20px" Width="50px" 
         AutoPostBack="True" CausesValidation="True" 
        MaxLength="4" Columns="4"></asp:TextBox>


        </td>

        <td>
        <asp:RegularExpressionValidator ID="regexpGraduated" runat="server"     
                                    ErrorMessage="You should enter a date." 
                                    ControlToValidate="Graduated"     
                                    ValidationExpression="^[0-9]{4}$" 
                                     display="dynamic" />
        </td>
</tr>

<tr>
<td valign="middle" align="right" class="style6">

<asp:Label ID="Degree_label" 
        runat="server" Text="Degree:" AssociatedControlID="Degree" 
        align="left" Font-Bold="True" Font-Strikeout="False"></asp:Label>

</td>
<td valign="top" align="left">
<asp:TextBox 
        ID="Degree" runat="server" Height="20px" Width="117px" 
         AutoPostBack="True" CausesValidation="True" 
        MaxLength="30"></asp:TextBox>

        </td>

        <td>
        <asp:RegularExpressionValidator ID="regexpDegree" runat="server"     
                                    ErrorMessage="This expression does not validate." 
                                    ControlToValidate="Degree"     
                                    ValidationExpression="^[a-zA-Z'.\s]{1,40}$" />
        </td>
</tr>
<tr>
<td class="style6">
</td>
<td>
</td>
<td>
</td>
</tr>
<tr>
<td class="style6">
</td>
<td>
</td>
<td>
</td>
</tr>
<tr>
<td colspan="3">
<h2>Application Questions</h2>

</td>
</tr>
              
                  
                      <tr>
                          <td colspan="3">
                          <ol>
                              <li><b>Why are you interested in this position of Conservation Training Intern? What 
                                  about the position intrigues you? </b>
                                  <br>
                                  <asp:TextBox ID="why" runat="server" clolumns="500" Height="72px" 
                                      MaxLength="2000" rows="10" TextMode="Multiline" Width="50%"></asp:TextBox>
                                 
                              </li>
                              </ol>
                             
                          </td>
                      </tr>
                      <tr>
                          <td colspan="3">
                          <ol>
                              <li><b>What would you hope to learn or to accomplish?<br/></b>
                                  <asp:TextBox ID="hope" runat="server" clolumns="500" Height="72px" 
                                      MaxLength="2000" rows="10" TextMode="Multiline" Width="50%"></asp:TextBox>
                              </li>
                              </ol>
                          </td>
                      </tr>
                      <tr>
                          <td colspan="3">
                              <ol>
                              <li><b>What kind of experience do you have in either organizing events, running 
                                  meetings or as a trainer?</b><br>
                                  <asp:TextBox ID="experience" runat="server" clolumns="500" Height="72px" 
                                      MaxLength="2000" rows="4" TextMode="Multiline" Width="50%"></asp:TextBox>
                                 </li>
                                 </ol>
                          </td>
                      </tr>
                      <tr>
                          <td colspan="3">
                              <ol>
                              <li><b>Tell me a little bit about your availability, what does your schedule look 
                                  like and what would work for you in terms of being part of our team?</b><br>
                                  <asp:TextBox ID="availability" runat="server" clolumns="40" Height="72px" 
                                      MaxLength="2000" rows="10" TextMode="Multiline" Width="50%"></asp:TextBox>
                               </li>
                               </ol>
                          </td>
                      </tr>
                      <tr>
                          <td colspan="3">
                          </td>
                      </tr>
                      <tr>
                          <td colspan="3">
                              <b>Specifically, please let me know days of the week you are available</b>
                              <asp:CheckBoxList ID="days_of_week" runat="server" AutoPostBack="True" 
                                  CausesValidation="True" Height="53px" RepeatDirection="Horizontal" 
                                  Width="455px" AppendDataBoundItems="True">
                                  <asp:ListItem Text="Monday" Value="Monday"></asp:ListItem>
                                  <asp:ListItem Text="Tuesday" Value="Tuesday"></asp:ListItem>
                                  <asp:ListItem Text="Wednesday" Value="Wednesday"></asp:ListItem>
                                  <asp:ListItem Text="Thursday" Value="Thursday"></asp:ListItem>
                                  <asp:ListItem Text="Friday" Value="Friday"></asp:ListItem>
                              </asp:CheckBoxList>
                             
                              <asp:Label ID="LabelResult" runat="server" Text=""></asp:Label>
                             
               
                              <asp:Label ID="ErrorMsg" runat="server" Text=""></asp:Label>
                             
                             

               
                              
                             
                             

               
                          </td>
                      </tr>
                    <tr>
                    <td colspan="3">
                
                    </td>
                    </tr>
                      <tr>
                          <td colspan="3">
                              <b>Time you are available</b><br/>
                              <asp:CheckBoxList ID="available" runat="server" AutoPostBack="True" 
                                  CausesValidation="True" RepeatDirection="Horizontal" Width="455px">
                                  <asp:ListItem Value="mornings">mornings (9-12 p.m.)</asp:ListItem>
                                  <asp:ListItem Value="afternoons">afternoons (1-5)</asp:ListItem>
                                  <asp:ListItem>other</asp:ListItem>
                              </asp:CheckBoxList>
                          </td>
                      </tr>
                      <tr>
                          <td colspan="3">
                          </td>
                      </tr>
                      <tr>
                          <td colspan="3">
                              <b>Dates available</b><br />
                              <table align="left" cellpadding="2" cellspacing="4" class="body">
                                  <tr>
                                      <td align="right" valign="middle">
                                          <asp:Label ID="Start_Date_label" runat="server" align="left" 
                                              AssociatedControlID="Start_Date" Font-Bold="True" Font-Strikeout="False" 
                                              Text="Start Date:" valighn="middle"></asp:Label>
                                      </td>
                                      <td>
                                          <asp:TextBox ID="Start_Date" runat="server" AutoPostBack="True" 
                                              CausesValidation="True" Columns="10" Height="21px" MaxLength="8" Width="112px"></asp:TextBox>
                                      </td>
                                      <td align="right" valign="middle">
                                          <asp:Label ID="End_Date_label" runat="server" align="left" 
                                              AssociatedControlID="End_Date" Font-Bold="True" Font-Strikeout="False" 
                                              Text="End Date:" valighn="middle"></asp:Label>
                                          <td />
                                          <asp:TextBox ID="End_Date" runat="server" AutoPostBack="True" 
                                              CausesValidation="True" Columns="10" Height="20px" MaxLength="8" Width="112px"></asp:TextBox>
                                      </td>
                                  </tr>
                              </table>
                          </td>
                      </tr>
                      <tr>
                          <td colspan="3">
                          </td>
                      </tr>
                      <tr>
                          <td colspan="3">
                           
                          </td>
                      </tr>

                      <tr>
                          <td colspan="3">
                             <ol>
                              <li>
                                 
                                      <b>Do you have any questions for me? Let me know.</b><br>
                                      <asp:TextBox ID="additional_questions" runat="server" clolumns="40" 
                                          Height="72px" rows="4" TextMode="Multiline" Width="334px"></asp:TextBox>
                                 
                                </li>
                             </ol>
                          </td>
                      </tr>
                      <tr>
                          <td colspan="3">
                           
                          </td>
                      </tr>

                      <tr>
                     
                          <td colspan="3">
                             <p align="left" 
                                  style="text-align: justify; vertical-align: middle; text-indent: 20px">

Thanks for your interest in this internship.   Someone will be in touch with you to let you know the status of
 your application, set up an interview or request additional materials.  These materials would include:  a brief
  cover letter, a resume and a writing sample (flyers for events you have organized - rally, concert, etc. welcome too!).
 </p> 
                          </td>
                      </tr>
                                            <tr>
                          <td colspan="3">
                           
                          </td>
                      </tr>

                      <tr>
                          <td colspan="3">
                              File name:

        
    <asp:FileUpload ID="file_path2" runat="server" />
                        </td>  
                      </tr>
                      <tr>
                          <td colspan="3">
                             
                          </td>
                      </tr>
                      <tr>
                          <td colspan="3">
                             <asp:checkbox id="cbxInProgress" Runat="server" 
    Text="In Progress" tabIndex="1" onmouseout="BlurThenRefocus()">
</asp:checkbox>  
<asp:checkbox id="cbxComplete" Runat="server" Text="Complete" 
    tabIndex="2" onmouseout="BlurThenRefocus()">
</asp:checkbox>  
<asp:checkbox id="cbxCancelled" Runat="server" Text="Cancelled" 
    tabIndex="3" onmouseout="BlurThenRefocus()">
</asp:checkbox>  

                          </td>
                      </tr>
                      <tr>
                          <td colspan="3">
    <div style="background:#efefef;">
    <div style="padding: 8px 10px;">   
    
    </div>
    </div>
                              
                          </td>
                      </tr>
                      <tr>
                          <td colspan="3" align="center">
                              
                              <asp:Button ID="Submit" runat="server" Text="Submit" Height="27px" 
                                  Width="76px" />
                              
                          </td>
                      </tr>
                      <tr>
                          <td class="style6">
                              &nbsp;</td>
                          <td>
                          </td>
                          <td>
                          </td>
                      </tr>
                      <tr>
                          <td class="style6">
                              &nbsp;</td>
                          <td>
                          </td>
                          <td>
                          </td>
                      </tr>
                      <tr>
                          <td class="style6">
                              &nbsp;</td>
                          <td>
                          </td>
                          <td>
                          </td>
                      </tr>
                      
             

</table> 
    
    </div>
    </form>
</body>
</html>
Be a part of the DaniWeb community

We're a friendly, industry-focused community of 1.20 million developers, IT pros, digital marketers, and technology enthusiasts learning and sharing knowledge.