Custom validation method doesn’t fired if it used with textbox control and its value is empty

Standard

​To avoid using of the ValidatorEnable method to disable required field validator at some cases on textbox control I decided to use custom validator as a required field just like the following:

<asp:CustomValidator ID="_examDateCustomValidator" runat="server" Text="*"
 ClientValidationFunction="CustomValidateDDL" ControlToValidate="_textbox">

And here is the javascript validation method

function CustomValidateDDL(sender, args)
{
  if (args.Value == "")
      args.IsValid = false;
  else
       args.IsValid = true;
}

unfortunatily I found that this method is working well if I compare the value with any other value except empty text

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s