I have a text box like below :
<asp:TextBox ID="headertxtUserName" runat="server" Text="User Name" onfocus="onfocusOfUserName(this);"
onblur="onblurOfUserName(this);" CssClass="header-login-input" ValidationGroup="A" Font-Names="Tahoma">
</asp:TextBox>
as you see there is a default text = “User Name” in that text box.
which validator should i use for this text box for purpose below :
when Text=”User Name” or Text=”” returns false.
when Text!=”User
Name” or Text!=”” returns true.
I know we can use CustomValidators!
but i don’t want any postback, so what can I do?
You can use a RegularExpressionValidator in combination with a RequiredFieldValidator control for this. It will validate the value of the textbox on the client, without a postback.
My syntax below may be slightly off. I’m not near a PC with Visual Studio, so I’m doing this off the top of my head. Please forgive me if I spelled something wrong.