RegularExpressionValidator question..

Last post 05-09-2008 9:13 AM by madhu_panisetty. 7 replies.

Sort Posts:

  • RegularExpressionValidator question..

    05-09-2008, 5:12 AM
    • Loading...
    • som.nitk
    • Joined on 01-09-2008, 9:05 AM
    • Posts 99

    I have a login form where user logs in to server..

    I have two textboxes, EmailID and Password and no gaps between them..

    I want to add a RegularExpressionValidator(for validating email) in such a manner that the error message from it shows just between the email textbox and passowrd..

    How to do this? I dont have space in the right side of my login form so that I can place these controls there..

    And I cant place this control between my textboxes otherwise therewould be gap, which wouldnt look good..

    The gap should be placed at runtime and the error message shown in red..

    Can anyone help me please?

    Dont forget to click "Mark as Answer" on the post that helped you.
    This credits the member,earns you a point & marks your thread as Resolved so that new users will know where to search for their queries.
  • Re: RegularExpressionValidator question..

    05-09-2008, 5:23 AM

     

    There is a display setting on validators with two values, static and dynamic. You want dynamic. Then it will only take up space if there is an error.
    If this answered your question, be sure to mark it as the answer. That way, everybody after you will know it's the answer also!
  • Re: RegularExpressionValidator question..

    05-09-2008, 5:45 AM
    • Loading...
    • som.nitk
    • Joined on 01-09-2008, 9:05 AM
    • Posts 99

    david wendelken:
    There is a display setting on validators with two values, static and dynamic. You want dynamic. Then it will only take up space if there is an error.

    But that is not exactly what I want..

    I want it to be between two textboxes, dynamically..And in the design view there is no space between my textboxes.. It should be created at runtime..

    Please read my Post.. I think you misunderstood what I meant..

    Dont forget to click "Mark as Answer" on the post that helped you.
    This credits the member,earns you a point & marks your thread as Resolved so that new users will know where to search for their queries.
  • Re: RegularExpressionValidator question..

    05-09-2008, 6:36 AM

    There is an easy way to do this, and a hard way.  You are asking to do it the hard way, but the reasons you gave for doing so are mistaken.

    So I'm going to explain the easy way again.

    You can always drag a control between two other textboxes.  Doesn't matter whether there is space there in the designer view or not.  Just drag the validator between the two textboxes and it will make space.  If you have trouble doing that, switch the view to source code mode and drag the validator between the two textboxes.

    If you set the validator's property to dynamic instead of static, it will only take up space on the rendered page that the user sees if there is an error. Otherwise, it will take up no space in the page the user sees.

    You can, of course, go to all the trouble to add the validation control at runtime.  That's extra lines of code and headache just to get the validation control put in the exact same place with the exact same property settings.

    Best of luck, and give it a try!
     

    If this answered your question, be sure to mark it as the answer. That way, everybody after you will know it's the answer also!
  • Re: RegularExpressionValidator question..

    05-09-2008, 7:06 AM
    • Loading...
    • som.nitk
    • Joined on 01-09-2008, 9:05 AM
    • Posts 99
    This is the peice of code I tested.. 
     
    1    <div>
    2       <asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>        
    3          <br />
    4            <asp:RequiredFieldValidator ID="RequiredFieldValidator1" ControlToValidate="TextBox1" runat="server" 
    5                ErrorMessage="RequiredFieldValidator" Display="Dynamic"></asp:RequiredFieldValidator>                   
    6            <asp:TextBox ID="TextBox2" runat="server"></asp:TextBox>
    7          <br />
    8        <asp:Button ID="Button1" runat="server" Text="Button" />        
    9    </div>
    
      
    Now the problem here is that when I click the button, the second textbox is pushed aside when the validator spits the message on to the screen..

    Please help me..

    Thanks..

    Dont forget to click "Mark as Answer" on the post that helped you.
    This credits the member,earns you a point & marks your thread as Resolved so that new users will know where to search for their queries.
  • Re: RegularExpressionValidator question..

    05-09-2008, 8:36 AM
    • Loading...
    • smcirish
    • Joined on 04-16-2007, 9:27 PM
    • Texas
    • Posts 175

    http://forums.asp.net/t/1174006.aspx

    See this post on using REGEX with your existing text boxes. 

     

    ~ Remember To Mark The Posts Which Helped You As The ANSWER ~
    Filed under:
  • Re: RegularExpressionValidator question..

    05-09-2008, 9:08 AM

    Hi, you used <br/> in wrong place

    check this code

     

        <div>    
            <asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>        
                <asp:RequiredFieldValidator ID="RequiredFieldValidator1" ControlToValidate="TextBox1" runat="server"             
                    ErrorMessage="RequiredFieldValidator" Display="Dynamic">* Required</asp:RequiredFieldValidator>            
              <br />                       
              <asp:TextBox ID="TextBox2" runat="server"></asp:TextBox>
              <br />
           <asp:Button ID="Button1" runat="server" Text="Button" />       
        </div>
    
      
    -----------
    :) MAdHU
    -----------
  • Re: RegularExpressionValidator question..

    05-09-2008, 9:13 AM
    Answer

     I think this works perfectly for you

     

            <table>
                <tr>
                    <td>
                        <asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>        
                    </td>
                </tr>
                <tr>
                    <td>
                        <asp:RequiredFieldValidator ID="RequiredFieldValidator1" ControlToValidate="TextBox1" runat="server"             
                            ErrorMessage="RequiredFieldValidator" Display="Dynamic">* Required</asp:RequiredFieldValidator>            
                    </td>
                </tr>
                <tr>
                    <td>
                          <asp:TextBox ID="TextBox2" runat="server"></asp:TextBox>
                    </td>
                </tr>
           </table>
           <asp:Button ID="Button1" runat="server" Text="Button" />       
    
      
    -----------
    :) MAdHU
    -----------
Page 1 of 1 (8 items)