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

  • Home
  • SEARCH
  • 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 171511
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T13:00:02+00:00 2026-05-11T13:00:02+00:00

This has not happened to me before, but for some reason both the client

  • 0

This has not happened to me before, but for some reason both the client and server side validation events are not being triggered:

<asp:TextBox ID='TextBoxDTownCity' runat='server' CssClass='contactfield' /> <asp:CustomValidator ID='CustomValidator2' runat='server' EnableClientScript='true'     ErrorMessage='Delivery Town or City required'     ClientValidationFunction='TextBoxDTownCityClient'      ControlToValidate='TextBoxDTownCity'     OnServerValidate='TextBoxDTownCity_Validate' Display='Dynamic' > </asp:CustomValidator> 

Server-side validation event:

protected void TextBoxDTownCity_Validate(object source, ServerValidateEventArgs args) {     args.IsValid = false; } 

Client-side validation event:

function TextBoxDCountyClient(sender, args) {     args.IsValid = false;     alert('test'); } 

I thought at the least the Server Side validation would fire but no. this has never happened to me before. This has really got me stumped.

I looked at the output and ASP.NET is recognizing the client side function:

ASP.NET JavaScript output:

var ctl00_ctl00_content_content_CustomValidator2 = document.all ? document.all['ctl00_ctl00_content_content_CustomValidator2'] : document.getElementById('ctl00_ctl00_content_content_CustomValidator2');  ctl00_ctl00_content_content_CustomValidator2.controltovalidate = 'ctl00_ctl00_content_content_TextBoxDTownCity';  ctl00_ctl00_content_content_CustomValidator2.errormessage = 'Delivery Town or City required';  ctl00_ctl00_content_content_CustomValidator2.display = 'Dynamic';  ctl00_ctl00_content_content_CustomValidator2.evaluationfunction = 'CustomValidatorEvaluateIsValid';  ctl00_ctl00_content_content_CustomValidator2.clientvalidationfunction = 'TextBoxDTownCityClient'; 

Rendered custom validator:

<span id='ctl00_ctl00_content_content_CustomValidator2' style='color:Red;display:none;'>Delivery Town or City required</span>  

Can any one shed some light as to why both client and server side validation would not be firing.

Edit: Typo I pasted in the wrong function, problem still the same

Just another update to the last comment: where by the TextBox cannot be empty. I tested this out and it is not true. On a blank page the CustomValidator fired my client side validation function fine without a value:

<asp:TextBox ID='TextBox1' runat='server' /> <asp:CustomValidator ID='CustomValidator1' runat='server'  ErrorMessage='CustomValidator' ClientValidationFunction='TextBoxDAddress1Client'></asp:CustomValidator> <asp:Button ID='Button1' runat='server' Text='Button' onclick='Button1_Click' /> 
  • 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. 2026-05-11T13:00:03+00:00Added an answer on May 11, 2026 at 1:00 pm

    Your CustomValidator will only fire when the TextBox isn’t empty.

    If you need to ensure that it’s not empty then you’ll need a RequiredFieldValidator too.

    Note: If the input control is empty, no validation functions are called and validation succeeds. Use a RequiredFieldValidator control to require the user to enter data in the input control.

    EDIT:

    If your CustomValidator specifies the ControlToValidate attribute (and your original example does) then your validation functions will only be called when the control isn’t empty.

    If you don’t specify ControlToValidate then your validation functions will be called every time.

    This opens up a second possible solution to the problem. Rather than using a separate RequiredFieldValidator, you could omit the ControlToValidate attribute from the CustomValidator and setup your validation functions to do something like this:

    Client Side code (Javascript):

    function TextBoxDCountyClient(sender, args) {     var v = document.getElementById('<%=TextBoxDTownCity.ClientID%>').value;     if (v == '') {         args.IsValid = false;  // field is empty     }     else {         // do your other validation tests here...     } } 

    Server side code (C#):

    protected void TextBoxDTownCity_Validate(     object source, ServerValidateEventArgs args) {     string v = TextBoxDTownCity.Text;     if (v == string.Empty)     {         args.IsValid = false;  // field is empty     }     else     {         // do your other validation tests here...     } } 
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 256k
  • Answers 256k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer If you want to determine if it's a left or… May 13, 2026 at 10:35 am
  • Editorial Team
    Editorial Team added an answer An easy and quick fix to this would be to… May 13, 2026 at 10:35 am
  • Editorial Team
    Editorial Team added an answer Yes it would improve your site. Depending on how much… May 13, 2026 at 10:35 am

Related Questions

Note: There is a very similar question here . Bear with me, however; my
For some reason neither the accepted answer nor any others work for me for
I was under the impression, after reading this article that it is better to
Background I'm using UKCrashReporter in my app. I've installed my own Uncaught Exception Handler.

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.