Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6947115
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T13:39:10+00:00 2026-05-27T13:39:10+00:00

I have a text box like below : <asp:TextBox ID=headertxtUserName runat=server Text=User Name onfocus=onfocusOfUserName(this);

  • 0

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?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T13:39:10+00:00Added an answer on May 27, 2026 at 1:39 pm

    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.

    <asp:TextBox id="UserNameTextBox" runat="server" Text="User Name" /> 
    <asp:RegularExpressionValidator id="UserNameTextBoxRegexValidator" runat="Server" ControlToValidate="UserNameTextBox" ValidationExpression="^User Name$" ErrorMessage="please enter a user name" />
    <asp:RequiredFieldValidator id="UserNameTextBoxRequiredFieldValidator" runat="server" ControlToValidate="UserNameTextBox" ErrorMessage="please enter a user name" />
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have to give textbox control id like below <asp:TextBox ID=7_1 runat=server> It is
I have a multiline text box, and I'd like to display the user's current
I have a textbox where a user puts a string like this: hello world!
I have the webform with dropdown list, label and textbox. Like below: <asp:DropDownList ID=ddlTest
I'm using ASP.NET WebForms and using some validation like the following: <asp:TextBox runat=server ID=txtUserName
I have a table like below <table id=mytable> <tr><th>checked</th><th>id</th><th>text</th></tr> <tr><td><input id=cb1 type=checkbox name=checker1/></td><td>123</td><td>abc</td></tr> <tr><td><input
1) I have a text file below like this. Dilantha code 65 po Bo
I have a text input field like text box or text area. I want
i want to make a text box like stackoverflow have for the tag at
I have a textbox where a user inputs a number, like: 105.14 When I

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.