Copied to clipboard

Flag this post as spam?

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


  • Simon Dingley 1474 posts 3431 karma points c-trib
    Feb 15, 2013 @ 10:42
    Simon Dingley
    0

    Prevent Validation on page load

    Having just upgraded to 3.06 from v1 it's a lot better now that we have more control over the markup! The problem I am left with currently, and I may just be having a challenging day, is how to prevent validation on page load? We don't want all of the validation message displayed on page load only when the form is either submitted or you move between fields?

    Am I missing something obvious?

    Thanks, Simon

  • Jeroen Breuer 4909 posts 12266 karma points MVP 5x admin c-trib
    Feb 15, 2013 @ 17:55
    Jeroen Breuer
    0

    If you're having a Razor file which renders the form you can probably remove the validation code from there.

    Jeroen

  • Simon Dingley 1474 posts 3431 karma points c-trib
    Feb 15, 2013 @ 18:36
    Simon Dingley
    0

    I don't want to remove the validation code, I still want form validation just not on page load. The new version of contour declares the use of jquery.validate in the Form.cshtml file as follows:

    Html.EnableClientValidation();
    Html.EnableUnobtrusiveJavaScript();

    however I can't see where the call to validate on page load is coming from or how to prevent it.

  • Jeroen Breuer 4909 posts 12266 karma points MVP 5x admin c-trib
    Feb 16, 2013 @ 15:49
    Jeroen Breuer
    0

    If you don't want to have the form validation on page load than when do you want it? Maybe add an if statement around these 2 Html helpers so it will only be called when you want to?

    Jeroen

  • Comment author was deleted

    Feb 18, 2013 @ 09:15

    Hmm validation shouldn't happen on page load, @Simon does this also happen when you preview the form in the Contour section?

  • Simon Dingley 1474 posts 3431 karma points c-trib
    Feb 18, 2013 @ 09:37
    Simon Dingley
    0

    @Tim, yes it does. All required field even in preview mode say "Field Name is a required field" beside them.

    @Jeroen, as with most forms the client would like validation to occur either when the form is submitted or your navigate from one field to another e.g. onblur. 

    Thanks, Simon

  • Comment author was deleted

    Feb 18, 2013 @ 09:40

    @Simon could you post a screenshot of the form settings tab?

  • Comment author was deleted

    Feb 18, 2013 @ 09:42

    Well is there something setup in the indicator part? That will always show

  • Simon Dingley 1474 posts 3431 karma points c-trib
    Feb 18, 2013 @ 09:44
    Simon Dingley
    0

    Interesting, since you asked me to do that it's obvious that the messages displayed do not reflect the "required error message" format defined in the settings?

  • Comment author was deleted

    Feb 18, 2013 @ 09:46

    Looks like you might have gotten the jquery validate defaults, care to share the umbraco/contour versions? then I'll see if I can reproduce

  • Comment author was deleted

    Feb 18, 2013 @ 09:49

    Tried with the same settings but don't see it, still only triggers on submit... did you customize the views?

  • Simon Dingley 1474 posts 3431 karma points c-trib
    Feb 18, 2013 @ 09:49
    Simon Dingley
    0

    Sure, Umbraco 4.11.1 and Contour 1.1.10 with the 3.0.6 upgrade.

  • Comment author was deleted

    Feb 18, 2013 @ 09:51

    Ok thanks will see if I can reproduce

    btw do you get any js errors?

  • Comment author was deleted

    Feb 18, 2013 @ 10:01

    Just tried (with upgrade from 1.1.10 to 3.0.6) and I don't get the issue

    Any chance I can take a look at the installation that has the issue, you can mail details to tg at umbraco dot com

    Thanks,
    Tim 

  • Simon Dingley 1474 posts 3431 karma points c-trib
    Feb 18, 2013 @ 10:32
    Simon Dingley
    0

    Sure, I will send over details now.

  • Comment author was deleted

    Feb 18, 2013 @ 11:33

    Ok issue is because the form view was modified, the part that is outputting the validation message was changed 

    from 

     @if (Model.ShowFieldValidaton)

                                    {

                                        @Html.ValidationMessage(f.Id)

                                    }

    to

                                     @if (Model.ShowFieldValidaton)

                                    {

                                        if (!string.IsNullOrEmpty(f.RequiredErrorMessage))

                                        {

                                            @Html.ValidationMessage(f.Id, f.RequiredErrorMessage)

                                        }

                                        else

                                        {

                                            @Html.ValidationMessage(f.Id, string.Empty)

                                        }

                                    }

    and it appears that that is causing the message to be displayed on load

  • Simon Dingley 1474 posts 3431 karma points c-trib
    Feb 18, 2013 @ 11:42
    Simon Dingley
    0

    This has been done (and already tried) and does not seem to correct the issue.

  • Comment author was deleted

    Feb 18, 2013 @ 11:51

    Just tested on local install and that did the trick , mailed you the updated view :)

Please Sign in or register to post replies

Write your reply to:

Draft