I just found out this weird behavior, is this a bug or what am I missing?
<asp:TextBox runat="server" Text="" ID="txtSomething" />
<asp:RequiredFieldValidator
ErrorMessage="errormessage"
ControlToValidate="txtSomething"
runat="server"
Text="(*) Required"
SetFocusOnError="true"
EnableClientScript="true"/>
With this simple code, validation works correctly, even if I write a string full of white spaces
But if I add the InitialValue property like this:
<asp:TextBox runat="server" Text="lol" ID="txtSomething" />
<asp:RequiredFieldValidator
ErrorMessage="errormessage"
ControlToValidate="txtSomething"
runat="server"
Text="(*) Required"
SetFocusOnError="true"
EnableClientScript="true"
InitialValue="lol"/>
Note I added InitialValue=”lol” and Text=”lol”
Now if I delete the text lol validation is ignored
Why??
Look carefully at MSDN description:
I think it speaks for itself.