SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have custom application page, and I need some custom client side validation. After spending hours on trying to make CustomValidator to work, I googled a lil bit and found few posts, that advise to use InputFormCustomValidator, instead of based CustomValidator. From what I see there is no big difference between two controls ( well maybe 2 or 3 additional properties that InputFormCustomValidator supports ).

I have a textbox, and jQuery datepicker, when user clicks on submit button I just want to check what option is selected on the dropdownlist on the form, and than based on the selected value, I need to check if textbox has any input. This is what I have so far.

<asp:TextBox ID="txtProjectStartDate" runat="server" Width="75" />
<SharePoint:InputFormCustomValidator ID="InputFormCustomValidator1" runat="server" ControlToValidate="txtProjectStartDate"
 ClientValidationFunction="ValidateProjectStartDate" ErrorMessage="*" EnableClientScript="true" />

and this is custom validation function

function ValidateProjectStartDate(sender, args) {

    var projectType = $('select[id*=ddlProjectType]').val();

    if (parseInt(projectType) != 1) {

        var startDate = $('input[type=text][id*=txtProjectStartDate]').val();

        if (startDate.length == 0) {
            args.IsValid = false;
        else {
            args.IsValid = true;

I have checked, there is no js error on my page, but custom validator doesn't fire. I have even tried to handle submit button click event, and programmatically force Validation, but no luck so far. If you've successfully used CustomValidator control in similar scenarios, I'd be glad to switch to CustomValidator as well.

Can anybody help me to make this code work ?

share|improve this question
up vote 2 down vote accepted

I figure this out, the problem was, I was testing with empty values, more exactlly I was left TextBox blank, and click on Submit button. But neither CustomValidator nor InputFormCustomValidator don't work with Empty values, unless ValidateEmptyText property is set to true. So all I was needed is to set ValidateEmptyText property to true. Now it works as expected. Hope this helps somebody else.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.