Unwanted spaces added by Validators

T

tshad

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
 
I

IPGrunt

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?

--
 
T

tshad

IPGrunt said:
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
 
I

IPGrunt

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
 
T

tshad

IPGrunt said:
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
 
I

IPGrunt

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

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

--
 
T

tshad

IPGrunt said:
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
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,754
Messages
2,569,522
Members
44,995
Latest member
PinupduzSap

Latest Threads

Top