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 7810137
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T03:39:57+00:00 2026-06-02T03:39:57+00:00

I have a server side customvalidator. Because it is not firing, so I want

  • 0

I have a server side customvalidator. Because it is not firing, so I want to use client side to validate a textbox. It include active directory something. I am not sure can we convert the code to client side?

<td class="style4">
            <asp:TextBox ID="TextUserName" runat="server"></asp:TextBox>
        </td><td><asp:CustomValidator ID="CustomValidatorUser" runat="server" ControlToValidate="TextUserName"
                                ErrorMessage="Minimum of 6 (six) alphanumeric characters." 
                OnServerValidate="ValidateUser" Display="Dynamic"
                                ValidateEmptyText="True" ></asp:CustomValidator></td>

And

 protected void ValidateUser(object source, ServerValidateEventArgs args)
 {
        string UserNameCreated = TextUserName.Text;
        string AD_Server = System.Configuration.ConfigurationManager.AppSettings["AD_Server"];
        DirectoryEntry entry = new DirectoryEntry(AD_Server);
        entry.AuthenticationType = AuthenticationTypes.Secure;

        DirectorySearcher deSearch = new DirectorySearcher(entry);
        deSearch.Filter = "(&(objectClass=user)(samaccountname=" + UserNameCreated + "))";

        SearchResultCollection results = deSearch.FindAll();
        Match match = Regex.Match(args.Value, @"^[a-zA-Z0-9]{6,}$",
    RegexOptions.IgnoreCase);
            if (results.Count > 0)
            args.IsValid = false;
        else if (match.Success)
            args.IsValid = true;
        // true means that it is validated. 
        else
            args.IsValid = false;
 }

My thought:

Fist:

<td class="style4">
            <asp:TextBox ID="TextUserName" runat="server"></asp:TextBox>
        </td><td><asp:CustomValidator ID="CustomValidatorUser" runat="server" ControlToValidate="TextUserName"
                                ErrorMessage="Minimum of 6 (six) alphanumeric characters." 
                ClientValidatationFunction="ValidateUser" Display="Dynamic"
                                ValidateEmptyText="True" ></asp:CustomValidator></td>

Second

<script language="javascript"> 
function ValidateUser(source, arguments)
{
    var RegularExpression = /^[a-zA-Z0-9]{6,}$/;
    if (arguments.Value.test(RegularExpression) == 0 ){
        arguments.IsValid = true;
    } else {
        arguments.IsValid = false;
    }
}
</script>

Then how about AD? Maybe it is a wrong question!!

Thanks.

  • 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-06-02T03:39:59+00:00Added an answer on June 2, 2026 at 3:39 am

    I don’t know exaclty how are you planning to use this code, if it’s related to authentication in any aspect you should perform all validations on server side since client code can be easily cracked.

    With this said, in case the security is not a problem, you could have a web method on the server to get results count. You would call this web method trough an ajax call.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a textbox and I do CustomValidation which does client side and server
i have a rhel 4 server and use php as a server side scripting
I try to use Richfaces DataTable with DataTableModel to have server side paging and
I know that we have client side controls and we have server side controls.
I have a server-side templating engine, Jade, which I use to render a layout.
I have an server side object which I am posting to the client and
I have server side controls like textbox, dropdownlsit etc on aspx page and my
I have a chrome extension which have a server-side javascript and I need this
I have an expensive server side resource ( which is thread safe ). What
If I have pages having server-side code in code-behind, then I know that the

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.