Click here to Skip to main content
15,905,686 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have a multi view control with 2 view.
There are one textbox in each view, that I want to check them not to be empty with java script function.
JavaScript
function check() 
{
      if (freetextboxEmpty() && textboxEmpty()) {
           if (confirmation()) {
                return true;
           }
      }                        

      return false;
}

function freetextboxEmpty() 
{
      var x = document.getElementById('<%=FreeTextBox1.ClientID%>').value;

      if (x == '')
          return false;
      else
          return true;
}

function textboxEmpty() 
{
      var x = document.getElementById('<%=Sub_txt.ClientID%>').value;

      if (x == '')
          return false;
      else
          return true;
}

I put the check function in OnClientClick event of button.

freetextboxEmpty() function check the emptyness of textbox in view 1 and textboxEmpty() function check the textbox in view 2.

My problem is when I am in view 1 and press button, js function check the first textbox and not the second textbox in view 2 and when I am in view 2, js function does not work.
ASP.NET
<asp:Button ID="Save_btn" 
            runat="server" 
            Text="save"  
            CssClass="Initial" 
            onclick="Save_btn_Click" 
            Width="100px" 
            OnClientClick="return check();" />

<asp:MultiView ID="MainView1" runat="server">        
       <asp:View ID="View11" runat="server"> 
              <asp:TextBox ID="Sub_txt" 
                           runat="server" 
                           Font-Size="Larger" 
                           Height="35px" 
                           Width="95%"></asp:TextBox>
       </asp:View>  
       
       <asp:View ID="View12" runat="server"> 
              <asp:TextBox ID="FreeTextBox1" runat="Server"/>
       </asp:View>              
</asp:MultiView>
Posted
v4
Comments
sandeep207 4-Mar-13 3:44am    
Please provide source code for better understanding
More information required.
MJ MOUSAVI 4-Mar-13 4:43am    
I post more information

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900