views:

18

answers:

1

I have multiple validators on a textbox (see structure below). When the RequiredFieldValidator passes but the CustomValidator fails there is a gap between the Textbox and the CustomValidator as the RequiredsFieldValidator has a Hidden CSS property.

[FieldLabel] [TextBox] [RequiredFieldValidator] [CustomValidator]

The HTML output from the validators can be seen below.

<input name="...Age" value="65" id="...Age" type="text">
<span id="...RequiredFieldValidator" style="color: rgb(195, 1, 185); visibility: hidden;">required</span>
<span id="...CustomValidator" style="color: rgb(195, 1, 185); visibility: visible;">must be between 55 and 74</span>

How can I make sure there is no space between the textbox and CustomValidator?

+2  A: 

set Display="Dynamic" property of Validator

MSDN: ASP.NET Validation in Depth

Azhar