开发者

Asp net validation error message is never display

I'm using a RequiredFieldValidator to check a field as follow :

<asp:TextBox runat="server" ID="field" Text=""></asp:TextBox>
<asp:RequiredFieldValidator ID="fieldValidator" runat="server" ControlToValidate="field" Display="Dynamic" SetFocusOnError="true" Text="*" />

I use dynamic display because I don't want the validator to eat space in my page if the input is right. The validator is rendered like this when the input is fine :

<span id="开发者_如何学JAVAmessageError" style="color: Red; display: none; visibility: hidden;">Numeric format required</span>

My issue is when the validation fires an error, the message switch to "display: inline" but is still "visibility: hidden", so it is never displayed

<span id="messageError" style="color: Red; display: inline; visibility: hidden;">* Required</span>

Am I missing something?

Thanks


You have to use the ErrorMessage="*" property instead of Text="*"

It should be like...

<asp:RequiredFieldValidator ID="fieldValidator" runat="server" ControlToValidate="field"
Display="Dynamic" SetFocusOnError="true" ErrorMessage="*" />
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜