Unwanted spaces added by Validators

Discussion in 'ASP .Net' started by tshad, Jan 26, 2005.

  1. tshad

    tshad Guest

    I have the following on one of my Textboxes:

    <asp:RequiredFieldValidator
    ControlToValidate="email"
    Text="Email Required"
    runat="server" />
    <asp:RegularExpressionValidator ControlToValidate="email" Text =
    "Invalid Email Address!"
    ValidationExpression="\S+@\S+\.\S{2,3}" runat="server" />
    <asp:CustomValidator
    ControlToValide="email"
    OnServerVAlidate="ValidateEmail"
    Display="Dynamic"
    Text="Email already on File"
    runat="server" />

    I also have Required validators on 2 Textboxes above this one. If I don't
    enter anything, all the error messages line up. If I enter something, but
    one that in invalidated, I get a "&nbsp;" where the RequiredValidator is.
    This happens no matter what order I do it. If the Validator doesn't print a
    message, it prints a space.

    Is there some way to stop this? It just makes the page look out of line.

    Thanks,

    Tom
     
    tshad, Jan 26, 2005
    #1
    1. Advertising

  2. tshad

    IPGrunt Guest

    "tshad" <> confessed in news:uF$blU0AFHA.3120
    @TK2MSFTNGP12.phx.gbl:

    > I have the following on one of my Textboxes:
    >
    > <asp:RequiredFieldValidator
    > ControlToValidate="email"
    > Text="Email Required"
    > runat="server" />
    > <asp:RegularExpressionValidator ControlToValidate="email" Text =
    > "Invalid Email Address!"
    > ValidationExpression="\S+@\S+\.\S{2,3}" runat="server" />
    > <asp:CustomValidator
    > ControlToValide="email"
    > OnServerVAlidate="ValidateEmail"
    > Display="Dynamic"
    > Text="Email already on File"
    > runat="server" />
    >
    > I also have Required validators on 2 Textboxes above this one. If I don't
    > enter anything, all the error messages line up. If I enter something, but
    > one that in invalidated, I get a "&nbsp;" where the RequiredValidator is.
    > This happens no matter what order I do it. If the Validator doesn't print

    a
    > message, it prints a space.
    >
    > Is there some way to stop this? It just makes the page look out of line.
    >
    > Thanks,
    >
    > Tom
    >
    >
    >


    Have you tried laying out using tables?

    --
     
    IPGrunt, Jan 26, 2005
    #2
    1. Advertising

  3. tshad

    tshad Guest

    "IPGrunt" <> wrote in message
    news:Xns95E9F22593E2Aswiss127army001wrenc@130.133.1.4...
    > "tshad" <> confessed in news:uF$blU0AFHA.3120
    > @TK2MSFTNGP12.phx.gbl:
    >
    >> I have the following on one of my Textboxes:
    >>
    >> <asp:RequiredFieldValidator
    >> ControlToValidate="email"
    >> Text="Email Required"
    >> runat="server" />
    >> <asp:RegularExpressionValidator ControlToValidate="email" Text =
    >> "Invalid Email Address!"
    >> ValidationExpression="\S+@\S+\.\S{2,3}" runat="server" />
    >> <asp:CustomValidator
    >> ControlToValide="email"
    >> OnServerVAlidate="ValidateEmail"
    >> Display="Dynamic"
    >> Text="Email already on File"
    >> runat="server" />
    >>
    >> I also have Required validators on 2 Textboxes above this one. If I
    >> don't
    >> enter anything, all the error messages line up. If I enter something,
    >> but
    >> one that in invalidated, I get a "&nbsp;" where the RequiredValidator is.
    >> This happens no matter what order I do it. If the Validator doesn't
    >> print

    > a
    >> message, it prints a space.
    >>
    >> Is there some way to stop this? It just makes the page look out of line.
    >>
    >> Thanks,
    >>
    >> Tom
    >>
    >>
    >>

    >
    > Have you tried laying out using tables?


    They are in a table.

    Here is more of a snippet with 3 of the objects:

    ***************************************************************************
    <tr>
    <td align="right">Email Address: </td>
    <td><asp:textbox id="txtEmail" TextMode="SingleLine" Columns="32"
    runat="server" />
    <asp:RegularExpressionValidator
    ControlToValidate="txtEmail"
    Font-Size="10"
    Text = "Invalid Email Address!"
    ValidationExpression="\S+@\S+\.\S{2,3}"
    runat="server" />
    <asp:RequiredFieldValidator
    ControlToValidate="txtEmail"
    Font-Size="10"
    Text="You must enter an email"
    runat="server" />
    </td>
    </tr>
    <tr>
    <td align="right">Password</td>
    <td><asp:textbox id="txtPassword" TextMode="Password"
    Columns="32" runat="server" />
    <asp:RequiredFieldValidator
    ControlToValidate="txtPassword"
    Text="You must enter an password"
    Font-Size="10"
    runat="server" />
    <asp:CustomValidator
    ControlToValidate="txtEmail"
    OnServerValidate="ValidateEmail"
    Font-Size="10"
    Display="Dynamic"
    Text="Not Valid !"
    runat="server" />
    </td>
    </tr>
    <tr>
    <td>&nbsp;</td>
    <td><asp:CheckBox ID="SaveLogon" Runat=server
    />&nbsp;&nbsp;Remember Me?</td>
    </tr>
    *************************************************************************

    Tom
     
    tshad, Jan 27, 2005
    #3
  4. tshad

    IPGrunt Guest

    "tshad" <> confessed in news:ewpVXzIBFHA.2788
    @TK2MSFTNGP15.phx.gbl:

    > "IPGrunt" <> wrote in message
    > news:Xns95E9F22593E2Aswiss127army001wrenc@130.133.1.4...
    >> "tshad" <> confessed in news:uF

    $blU0AFHA.3120
    >> @TK2MSFTNGP12.phx.gbl:
    >>
    >>> I have the following on one of my Textboxes:
    >>>
    >>> <asp:RequiredFieldValidator
    >>> ControlToValidate="email"
    >>> Text="Email Required"
    >>> runat="server" />
    >>> <asp:RegularExpressionValidator ControlToValidate="email" Text

    =
    >>> "Invalid Email Address!"
    >>> ValidationExpression="\S+@\S+\.\S{2,3}" runat="server" />
    >>> <asp:CustomValidator
    >>> ControlToValide="email"
    >>> OnServerVAlidate="ValidateEmail"
    >>> Display="Dynamic"
    >>> Text="Email already on File"
    >>> runat="server" />
    >>>
    >>> I also have Required validators on 2 Textboxes above this one. If I
    >>> don't
    >>> enter anything, all the error messages line up. If I enter something,
    >>> but
    >>> one that in invalidated, I get a "&nbsp;" where the RequiredValidator

    is.
    >>> This happens no matter what order I do it. If the Validator doesn't
    >>> print

    >> a
    >>> message, it prints a space.
    >>>
    >>> Is there some way to stop this? It just makes the page look out of

    line.
    >>>
    >>> Thanks,
    >>>
    >>> Tom
    >>>
    >>>
    >>>

    >>
    >> Have you tried laying out using tables?

    >
    > They are in a table.
    >
    > Here is more of a snippet with 3 of the objects:
    >
    > *************************************************************************

    **
    > <tr>
    > <td align="right">Email Address: </td>
    > <td><asp:textbox id="txtEmail" TextMode="SingleLine"

    Columns="32"
    > runat="server" />
    > <asp:RegularExpressionValidator
    > ControlToValidate="txtEmail"
    > Font-Size="10"
    > Text = "Invalid Email Address!"
    > ValidationExpression="\S+@\S+\.\S{2,3}"
    > runat="server" />
    > <asp:RequiredFieldValidator
    > ControlToValidate="txtEmail"
    > Font-Size="10"
    > Text="You must enter an email"
    > runat="server" />
    > </td>
    > </tr>
    > <tr>
    > <td align="right">Password</td>
    > <td><asp:textbox id="txtPassword" TextMode="Password"
    > Columns="32" runat="server" />
    > <asp:RequiredFieldValidator
    > ControlToValidate="txtPassword"
    > Text="You must enter an password"
    > Font-Size="10"
    > runat="server" />
    > <asp:CustomValidator
    > ControlToValidate="txtEmail"
    > OnServerValidate="ValidateEmail"
    > Font-Size="10"
    > Display="Dynamic"
    > Text="Not Valid !"
    > runat="server" />
    > </td>
    > </tr>
    > <tr>
    > <td>&nbsp;</td>
    > <td><asp:CheckBox ID="SaveLogon" Runat=server
    > />&nbsp;&nbsp;Remember Me?</td>
    > </tr>
    > *************************************************************************
    >
    > Tom
    >
    >
    >


    What I do is use the static display. This way i know how much space they'll
    take up. Dynamic display doesn't always work like you think it will.

    -- ipgrunt
     
    IPGrunt, Jan 27, 2005
    #4
  5. tshad

    tshad Guest

    "IPGrunt" <> wrote in message
    news:Xns95EB6A5269406swiss127army001wrenc@130.133.1.4...
    > "tshad" <> confessed in news:ewpVXzIBFHA.2788
    > @TK2MSFTNGP15.phx.gbl:
    >
    >> "IPGrunt" <> wrote in message
    >> news:Xns95E9F22593E2Aswiss127army001wrenc@130.133.1.4...
    >>> "tshad" <> confessed in news:uF

    > $blU0AFHA.3120
    >>> @TK2MSFTNGP12.phx.gbl:
    >>>
    >>>> I have the following on one of my Textboxes:
    >>>>
    >>>> <asp:RequiredFieldValidator
    >>>> ControlToValidate="email"
    >>>> Text="Email Required"
    >>>> runat="server" />
    >>>> <asp:RegularExpressionValidator ControlToValidate="email" Text

    > =
    >>>> "Invalid Email Address!"
    >>>> ValidationExpression="\S+@\S+\.\S{2,3}" runat="server" />
    >>>> <asp:CustomValidator
    >>>> ControlToValide="email"
    >>>> OnServerVAlidate="ValidateEmail"
    >>>> Display="Dynamic"
    >>>> Text="Email already on File"
    >>>> runat="server" />
    >>>>
    >>>> I also have Required validators on 2 Textboxes above this one. If I
    >>>> don't
    >>>> enter anything, all the error messages line up. If I enter something,
    >>>> but
    >>>> one that in invalidated, I get a "&nbsp;" where the RequiredValidator

    > is.
    >>>> This happens no matter what order I do it. If the Validator doesn't
    >>>> print
    >>> a
    >>>> message, it prints a space.
    >>>>
    >>>> Is there some way to stop this? It just makes the page look out of

    > line.
    >>>>
    >>>> Thanks,
    >>>>
    >>>> Tom
    >>>>
    >>>>
    >>>>
    >>>
    >>> Have you tried laying out using tables?

    >>
    >> They are in a table.
    >>
    >> Here is more of a snippet with 3 of the objects:
    >>
    >> *************************************************************************

    > **
    >> <tr>
    >> <td align="right">Email Address: </td>
    >> <td><asp:textbox id="txtEmail" TextMode="SingleLine"

    > Columns="32"
    >> runat="server" />
    >> <asp:RegularExpressionValidator
    >> ControlToValidate="txtEmail"
    >> Font-Size="10"
    >> Text = "Invalid Email Address!"
    >> ValidationExpression="\S+@\S+\.\S{2,3}"
    >> runat="server" />
    >> <asp:RequiredFieldValidator
    >> ControlToValidate="txtEmail"
    >> Font-Size="10"
    >> Text="You must enter an email"
    >> runat="server" />
    >> </td>
    >> </tr>
    >> <tr>
    >> <td align="right">Password</td>
    >> <td><asp:textbox id="txtPassword" TextMode="Password"
    >> Columns="32" runat="server" />
    >> <asp:RequiredFieldValidator
    >> ControlToValidate="txtPassword"
    >> Text="You must enter an password"
    >> Font-Size="10"
    >> runat="server" />
    >> <asp:CustomValidator
    >> ControlToValidate="txtEmail"
    >> OnServerValidate="ValidateEmail"
    >> Font-Size="10"
    >> Display="Dynamic"
    >> Text="Not Valid !"
    >> runat="server" />
    >> </td>
    >> </tr>
    >> <tr>
    >> <td>&nbsp;</td>
    >> <td><asp:CheckBox ID="SaveLogon" Runat=server
    >> />&nbsp;&nbsp;Remember Me?</td>
    >> </tr>
    >> *************************************************************************
    >>
    >> Tom
    >>
    >>
    >>

    >
    > What I do is use the static display. This way i know how much space
    > they'll
    > take up. Dynamic display doesn't always work like you think it will.
    >


    I tried changing both to static and I still get the same thing.

    If I change the order, it works ok, only the &nbsp; is placed after the
    message, instead of before. Here is what gets generated:
    ********************************************************
    <td><input name="txtEmail" type="text" size="32" id="txtEmail" />
    <span><font color="Red" size="2">You must enter an
    email</font></span>
    &nbsp;
    </td>
    ********************************************************************

    Tom
    > -- ipgrunt
    >
     
    tshad, Jan 27, 2005
    #5
  6. tshad

    IPGrunt Guest

    "tshad" <> confessed in news:OIfa6fJBFHA.2792
    @TK2MSFTNGP15.phx.gbl:

    >
    > "IPGrunt" <> wrote in message
    > news:Xns95EB6A5269406swiss127army001wrenc@130.133.1.4...
    >> "tshad" <> confessed in

    news:ewpVXzIBFHA.2788
    >> @TK2MSFTNGP15.phx.gbl:
    >>
    >>> "IPGrunt" <> wrote in message
    >>> news:Xns95E9F22593E2Aswiss127army001wrenc@130.133.1.4...
    >>>> "tshad" <> confessed in news:uF

    >> $blU0AFHA.3120
    >>>> @TK2MSFTNGP12.phx.gbl:
    >>>>
    >>>>> I have the following on one of my Textboxes:
    >>>>>
    >>>>> <asp:RequiredFieldValidator
    >>>>> ControlToValidate="email"
    >>>>> Text="Email Required"
    >>>>> runat="server" />
    >>>>> <asp:RegularExpressionValidator ControlToValidate="email"

    Text
    >> =
    >>>>> "Invalid Email Address!"
    >>>>> ValidationExpression="\S+@\S+\.\S{2,3}" runat="server" />
    >>>>> <asp:CustomValidator
    >>>>> ControlToValide="email"
    >>>>> OnServerVAlidate="ValidateEmail"
    >>>>> Display="Dynamic"
    >>>>> Text="Email already on File"
    >>>>> runat="server" />
    >>>>>
    >>>>> I also have Required validators on 2 Textboxes above this one. If I
    >>>>> don't
    >>>>> enter anything, all the error messages line up. If I enter

    something,
    >>>>> but
    >>>>> one that in invalidated, I get a "&nbsp;" where the RequiredValidator

    >> is.
    >>>>> This happens no matter what order I do it. If the Validator doesn't
    >>>>> print
    >>>> a
    >>>>> message, it prints a space.
    >>>>>
    >>>>> Is there some way to stop this? It just makes the page look out of

    >> line.
    >>>>>
    >>>>> Thanks,
    >>>>>
    >>>>> Tom
    >>>>>
    >>>>>
    >>>>>
    >>>>
    >>>> Have you tried laying out using tables?
    >>>
    >>> They are in a table.
    >>>
    >>> Here is more of a snippet with 3 of the objects:
    >>>
    >>>

    *************************************************************************
    >> **
    >>> <tr>
    >>> <td align="right">Email Address: </td>
    >>> <td><asp:textbox id="txtEmail" TextMode="SingleLine"

    >> Columns="32"
    >>> runat="server" />
    >>> <asp:RegularExpressionValidator
    >>> ControlToValidate="txtEmail"
    >>> Font-Size="10"
    >>> Text = "Invalid Email Address!"
    >>> ValidationExpression="\S+@\S+\.\S{2,3}"
    >>> runat="server" />
    >>> <asp:RequiredFieldValidator
    >>> ControlToValidate="txtEmail"
    >>> Font-Size="10"
    >>> Text="You must enter an email"
    >>> runat="server" />
    >>> </td>
    >>> </tr>
    >>> <tr>
    >>> <td align="right">Password</td>
    >>> <td><asp:textbox id="txtPassword" TextMode="Password"
    >>> Columns="32" runat="server" />
    >>> <asp:RequiredFieldValidator
    >>> ControlToValidate="txtPassword"
    >>> Text="You must enter an password"
    >>> Font-Size="10"
    >>> runat="server" />
    >>> <asp:CustomValidator
    >>> ControlToValidate="txtEmail"
    >>> OnServerValidate="ValidateEmail"
    >>> Font-Size="10"
    >>> Display="Dynamic"
    >>> Text="Not Valid !"
    >>> runat="server" />
    >>> </td>
    >>> </tr>
    >>> <tr>
    >>> <td>&nbsp;</td>
    >>> <td><asp:CheckBox ID="SaveLogon" Runat=server
    >>> />&nbsp;&nbsp;Remember Me?</td>
    >>> </tr>
    >>>

    *************************************************************************
    >>>
    >>> Tom
    >>>
    >>>
    >>>

    >>
    >> What I do is use the static display. This way i know how much space
    >> they'll
    >> take up. Dynamic display doesn't always work like you think it will.
    >>

    >
    > I tried changing both to static and I still get the same thing.
    >
    > If I change the order, it works ok, only the &nbsp; is placed after the
    > message, instead of before. Here is what gets generated:
    > ********************************************************
    > <td><input name="txtEmail" type="text" size="32" id="txtEmail" />
    > <span><font color="Red" size="2">You must enter an
    > email</font></span>
    > &nbsp;
    > </td>
    > ********************************************************************
    >
    > Tom
    >> -- ipgrunt
    >>

    >
    >


    Have you considered putting the control and the validator in different
    columns?

    --
     
    IPGrunt, Jan 27, 2005
    #6
  7. tshad

    tshad Guest

    "IPGrunt" <> wrote in message
    news:Xns95EB710788573swiss127army001wrenc@130.133.1.4...
    > "tshad" <> confessed in news:OIfa6fJBFHA.2792
    > @TK2MSFTNGP15.phx.gbl:
    >
    >>
    >> "IPGrunt" <> wrote in message
    >> news:Xns95EB6A5269406swiss127army001wrenc@130.133.1.4...
    >>> "tshad" <> confessed in

    > news:ewpVXzIBFHA.2788
    >>> @TK2MSFTNGP15.phx.gbl:
    >>>
    >>>> "IPGrunt" <> wrote in message
    >>>> news:Xns95E9F22593E2Aswiss127army001wrenc@130.133.1.4...
    >>>>> "tshad" <> confessed in news:uF
    >>> $blU0AFHA.3120
    >>>>> @TK2MSFTNGP12.phx.gbl:
    >>>>>
    >>>>>> I have the following on one of my Textboxes:
    >>>>>>
    >>>>>> <asp:RequiredFieldValidator
    >>>>>> ControlToValidate="email"
    >>>>>> Text="Email Required"
    >>>>>> runat="server" />
    >>>>>> <asp:RegularExpressionValidator ControlToValidate="email"

    > Text
    >>> =
    >>>>>> "Invalid Email Address!"
    >>>>>> ValidationExpression="\S+@\S+\.\S{2,3}" runat="server" />
    >>>>>> <asp:CustomValidator
    >>>>>> ControlToValide="email"
    >>>>>> OnServerVAlidate="ValidateEmail"
    >>>>>> Display="Dynamic"
    >>>>>> Text="Email already on File"
    >>>>>> runat="server" />
    >>>>>>
    >>>>>> I also have Required validators on 2 Textboxes above this one. If I
    >>>>>> don't
    >>>>>> enter anything, all the error messages line up. If I enter

    > something,
    >>>>>> but
    >>>>>> one that in invalidated, I get a "&nbsp;" where the RequiredValidator
    >>> is.
    >>>>>> This happens no matter what order I do it. If the Validator doesn't
    >>>>>> print
    >>>>> a
    >>>>>> message, it prints a space.
    >>>>>>
    >>>>>> Is there some way to stop this? It just makes the page look out of
    >>> line.
    >>>>>>
    >>>>>> Thanks,
    >>>>>>
    >>>>>> Tom
    >>>>>>
    >>>>>>
    >>>>>>
    >>>>>
    >>>>> Have you tried laying out using tables?
    >>>>
    >>>> They are in a table.
    >>>>
    >>>> Here is more of a snippet with 3 of the objects:
    >>>>
    >>>>

    > *************************************************************************
    >>> **
    >>>> <tr>
    >>>> <td align="right">Email Address: </td>
    >>>> <td><asp:textbox id="txtEmail" TextMode="SingleLine"
    >>> Columns="32"
    >>>> runat="server" />
    >>>> <asp:RegularExpressionValidator
    >>>> ControlToValidate="txtEmail"
    >>>> Font-Size="10"
    >>>> Text = "Invalid Email Address!"
    >>>> ValidationExpression="\S+@\S+\.\S{2,3}"
    >>>> runat="server" />
    >>>> <asp:RequiredFieldValidator
    >>>> ControlToValidate="txtEmail"
    >>>> Font-Size="10"
    >>>> Text="You must enter an email"
    >>>> runat="server" />
    >>>> </td>
    >>>> </tr>
    >>>> <tr>
    >>>> <td align="right">Password</td>
    >>>> <td><asp:textbox id="txtPassword" TextMode="Password"
    >>>> Columns="32" runat="server" />
    >>>> <asp:RequiredFieldValidator
    >>>> ControlToValidate="txtPassword"
    >>>> Text="You must enter an password"
    >>>> Font-Size="10"
    >>>> runat="server" />
    >>>> <asp:CustomValidator
    >>>> ControlToValidate="txtEmail"
    >>>> OnServerValidate="ValidateEmail"
    >>>> Font-Size="10"
    >>>> Display="Dynamic"
    >>>> Text="Not Valid !"
    >>>> runat="server" />
    >>>> </td>
    >>>> </tr>
    >>>> <tr>
    >>>> <td>&nbsp;</td>
    >>>> <td><asp:CheckBox ID="SaveLogon" Runat=server
    >>>> />&nbsp;&nbsp;Remember Me?</td>
    >>>> </tr>
    >>>>

    > *************************************************************************
    >>>>
    >>>> Tom
    >>>>
    >>>>
    >>>>
    >>>
    >>> What I do is use the static display. This way i know how much space
    >>> they'll
    >>> take up. Dynamic display doesn't always work like you think it will.
    >>>

    >>
    >> I tried changing both to static and I still get the same thing.
    >>
    >> If I change the order, it works ok, only the &nbsp; is placed after the
    >> message, instead of before. Here is what gets generated:
    >> ********************************************************
    >> <td><input name="txtEmail" type="text" size="32" id="txtEmail" />
    >> <span><font color="Red" size="2">You must enter an
    >> email</font></span>
    >> &nbsp;
    >> </td>
    >> ********************************************************************
    >>
    >> Tom
    >>> -- ipgrunt
    >>>

    >>
    >>

    >
    > Have you considered putting the control and the validator in different
    > columns?
    >

    If I do that, the second message will show way over to the right.

    Tom
    > --
     
    tshad, Jan 27, 2005
    #7
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Ratman
    Replies:
    0
    Views:
    694
    Ratman
    Sep 14, 2004
  2. =?Utf-8?B?Q2hyaXM=?=

    validators with spaces?

    =?Utf-8?B?Q2hyaXM=?=, Mar 21, 2005, in forum: ASP .Net
    Replies:
    0
    Views:
    331
    =?Utf-8?B?Q2hyaXM=?=
    Mar 21, 2005
  3. Jeffrey Todd
    Replies:
    1
    Views:
    4,152
    Peter Blum
    Jun 2, 2005
  4. John B. Matthews
    Replies:
    4
    Views:
    684
    John B. Matthews
    Sep 12, 2008
  5. Replies:
    11
    Views:
    147
    Mark Lawrence
    Jan 27, 2014
Loading...

Share This Page