SaaS CMS has officially launched! Learn more now.

Adding custom validation in XForm


I want to add to validation on Age [RequiredFieldValidation and RegularExpressionValidator] which is in XForm.

If I add   <asp:ValidationSummary ID="ValidationSummary1" ValidationGroup="XForm" DisplayMode="BulletList" ShowSummary="true" EnableClientScript="true" runat="server" /> in the form in which XForm is loading it shows only one ErrorMessage for all validations.

You haven't specified all required fields

You haven't specified all required fields

You haven't specified all required fields

I also tried adding custom validation in global.asax.cs

 if (pg.CurrentPage.PageTypeName.Trim().ToLower() == "formname")
foreach (Control control in formControl.Controls)
if (control is BaseValidator)
((BaseValidator)control).ErrorMessage = LanguageManager.Instance.TranslateFallback("/xform/" + ((BaseValidator)control).ControlToValidate.Replace("_", "").ToLower().Trim(), "");


   but the problem is that it also show only one custom errormessage. But if i remove this code and keep the validation summary on the aspx page then after showing the errormessage "" it does show the second numeric message.


Any idea how can i add the custom errormessage and 2 validation.

Mar 01, 2011 5:37

What you'd need to do is hook the ControlCreated event of the XFormControl, then iterate through the controls collection.  When you find an IValidator control, you need to set a custom message in the ErrorMessage property.

Mar 05, 2011 20:19

See for an example.

Mar 06, 2011 22:44

Thanks, IValidator is adding the custom error message.

But I am trying to display the error message from my xml.

          <caption>E-mail address</caption>
          <inlineerrormessage>Not a valid e-mail address.</inlineerrormessage>
          <summaryerrormessage>* is not a valid e-mail address.</summaryerrormessage>

        <inlineerrormessage>This field is required</inlineerrormessage>
        <summaryerrormessage>You haven't specified all required fields</summaryerrormessage>

this is the xml which tag which is used to display message. I am not able to figure out how summaryerrormessage of required field and for a particular datatype is set.

Mar 17, 2011 6:27
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.