Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Mike Chambers 636 posts 1253 karma points c-trib
    Nov 23, 2010 @ 16:09
    Mike Chambers
    0

    customvalidator added via renderform.ascx has issues.

    I've created a custom compare validator to compare the text of two text boxes (in separate naming containers) added in the normal way through the contour form admin screens, basically a email and confirm email scenario that I need to check.

    All seems to work. Up to the point of hitting submit the submit button.

    By that I mean the clientside evaluation works and says the text in the two textboxes isn't the same.

    By leaving another mandatory field blank so that the form doesn't submit, clicking the submit button my customvalidator clientside evaluation then doesn't fire.

    Also if I complete the form apart from the textfields not matching and hit submit the form submits... even thought the EvaluateIsValid() server side validation on the customvalidator will be failing.

    All I can think is that on the submit button click you are manipulating the page.validators collection in order to hook up your Umbraco.Forms.Core.Controls.Validation.ValidationFieldExtenderBehavior???

    So my questions is

    Are you removing items and re-adding only your own validators to the page.validators collection? are you doing this both for client and server side validations?

    If this is the case is there a way I can use the Umbraco.Forms.Core.Controls.Validation.ValidationFieldExtender to include my validator to the collection which would be nice as it would then pick up the jquery extensions you use to indicate erroring validation fields.....

    thanks...

    (contour 1.1.3, umb 4.5.2, iis7, windows server 2008)

  • Mike Chambers 636 posts 1253 karma points c-trib
    Nov 23, 2010 @ 20:02
    Mike Chambers
    0

    so managed to figure out how to use the validationextender... 

                        Control ctrlLab = FindLabelRecursive(rpFieldsets, fieldId.Replace('-', '_'));

                        //compareValidator

                        UmbracoJPT.Contour.Validators.compare2Textboxes compareValidator = (UmbracoJPT.Contour.Validators.compare2Textboxes)FindControlRecursive(ctrlLab.Parent, "compare");

     

                        string compareTo = fields.Find(x => x.Caption == compareCtrl).Id.ToString();

     

                        Control validate = FindControlRecursive(rpFieldsets, fieldId.Replace('-', '_'));

                        Control compare = FindControlRecursive(rpFieldsets, compareTo.Replace('-', '_'));

     

                        Umbraco.Forms.Core.Controls.Validation.ValidationFieldExtender compareExtender = new Umbraco.Forms.Core.Controls.Validation.ValidationFieldExtender();

                        compareExtender.TargetLabelID = ctrlLab.UniqueID;

                        compareExtender.TargetControlID = compareValidator.UniqueID;

                        compareExtender.InvalidLabelCssClass = "contourError";

                        compareExtender.InvalidTextBoxCssClass = "contourError";

                        compareExtender.ValidLabelCssClass = "contourValid";

                        compareExtender.ValidTextBoxCssClass = "contourValid";

     

                        validate.Parent.Controls.Add(compareExtender);

     

    so now just need to find out how to hook into the submit button click....

  • Comment author was deleted

    Nov 24, 2010 @ 08:32

    Hi Mike,

    I guess it's just a matter of setting the correct validation group on your compare validator

    It needs to be set to the clientid of the RenderForm control

     

  • Mike Chambers 636 posts 1253 karma points c-trib
    Nov 25, 2010 @ 02:21
    Mike Chambers
    0

    that seems to solved that one.. I had based on some code from the farm, that used form.name as the validationgroup maybe that was for an older incarnation of contour.

Please Sign in or register to post replies

Write your reply to:

Draft