[thelist] asp.net: Why won't InitialValue work?

Casey Crookston casey at thecrookstons.com
Wed Dec 22 09:36:27 CST 2004

As illistrated on page 159 of ASP.NET Unleashed, I'm trying to use
InitialValue in a RequiredFieldValidator.

On the textbox "joined" I need to make it a required field AND validate the
format.  This is working fine, but what doesn't work is the InitialValue

If I include InitialValue="MM-DD-YYYY" in the RegularExpressionValidator,
nothing happens... it's like it's not even there.  If I include it in the
RequiredFieldValidator, it also does not display the initial value, AND the
validator stops working and allows an empty value.  What's with that?  How
can I make this work?

<form runat="server">

<asp:textbox id="joined" runat="server" />

<asp:RegularExpressionValidator id="revJoined" ControlToValidate="joined"
ErrorMessage="Formt: Enter Date: MM-DD-YYYY"  Display="Dynamic"
ValidationExpression="\d{2}-\d{2}-\d{4}" runat="server" />

<asp:RequiredFieldValidator id="rfvJoined" ControlToValidate="joined"
ErrorMessage="Required: Enter Date: MM-DD-YYYY" Display="Dynamic"
runat="server" />


More information about the thelist mailing list