ASP.NET Custom Validator Client side Server Side validation not firing
Master System Design with Codemia
Enhance your system design skills with over 120 practice problems, detailed solutions, and hands-on exercises.
Introduction
When an ASP.NET CustomValidator does not fire, the cause is usually not the validator itself. It is usually one of the surrounding conditions: the page never validated, the validator is in the wrong validation group, the client JavaScript function name is wrong, or server validation was bypassed by control flow.
Make Sure the Control Is Wired Correctly
A working CustomValidator needs the right properties and handler names.
And the matching client script:
And the server handler:
If any of these names or signatures do not match, validation will quietly fail to run.
Check the Validation Group
If your submit button uses a ValidationGroup, the validator and the input control must be in the same group.
A very common bug is having the button validate one group while the CustomValidator belongs to another or to no group at all.
Server Validation Only Happens When Page Validation Runs
Server-side validation does not magically execute on every postback. It runs when validation is triggered, either automatically by a validating control or explicitly through Page.Validate().
If the button has CausesValidation="false", the validator will not run unless you call Page.Validate() yourself.
Client Validation Depends on Script Availability
If client-side validation is not firing, check:
- the JavaScript function name matches exactly
- the script is present on the page
- there are no browser console errors stopping execution
- unobtrusive or script-manager setup is not broken
Client validation is convenience. Server validation is the real safety net.
ValidateEmptyText Matters
By default, some validators do not run on empty input. If you want your custom logic to inspect empty values too, set ValidateEmptyText="true" as shown earlier.
Without that, you may think the validator is broken when it is simply skipping blank input by design.
Debug One Layer at a Time
A practical troubleshooting order is: confirm the page posts back, confirm Page.Validate() runs, confirm the server handler executes, and only then debug the client script. That sequence prevents you from chasing JavaScript problems when the real issue is that validation was never triggered at all.
Layered debugging is much faster than changing markup and script at the same time.
Keep Server Validation Even When Client Validation Works
Client-side validation improves responsiveness, but it is never the trust boundary. Browsers can disable scripts, skip validation, or submit handcrafted requests. The server handler should therefore always be treated as the real enforcement path.
Common Pitfalls
The biggest mistake is forgetting that CustomValidator depends on the full validation flow around it, not just on one server method.
Another issue is mismatched validation groups between the validator and the submit button.
A third problem is relying only on the client-side function and never confirming that server-side validation still runs correctly.
Summary
- Verify the validator markup, JavaScript function, and server handler names all match.
- Make sure the validator and the triggering control use the same
ValidationGroup. - Call
Page.Validate()when validation is not triggered automatically. - Treat client-side validation as convenience, not as the only enforcement layer.
- Use
ValidateEmptyTextwhen empty inputs should still run through your custom logic.

