Copied to clipboard

Flag this post as spam?

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


  • Tom Martin 30 posts 72 karma points
    Mar 18, 2013 @ 15:21
    Tom Martin
    0

    Mandatory Checkbox

    Hello,

    I need to ensure that on my form submit can only happen if certain checkboxes are ticked (e.g. accept T&C's etc).

    Making them mandatory doesn't seem to have any effect - is there another way?

    Thanks

    Tom

  • Comment author was deleted

    Mar 18, 2013 @ 15:23

    Hmm that should work, what Contour version are you running?

  • Tom Martin 30 posts 72 karma points
    Mar 18, 2013 @ 15:33
    Tom Martin
    0

    Version 3.0

  • Comment author was deleted

    Mar 18, 2013 @ 16:13

    Ok I'll try to reproduce

  • Tom Martin 30 posts 72 karma points
    Mar 18, 2013 @ 16:47
    Tom Martin
    0

    hmm... now I've got the validation working, I can't submit the form at all - highlights the three text fields I have whic are mandatory, but once they are filled in, submit still won't do anything....

  • Tom Martin 30 posts 72 karma points
    Mar 18, 2013 @ 16:53
    Tom Martin
    0

    ignore that last post was an error on my part... the mandatory issue on cehck-boxes still exists though

  • Tom Martin 30 posts 72 karma points
    Mar 19, 2013 @ 10:59
    Tom Martin
    0

    Hi Tim

    did you manage to reproduce the issue?

    Thanks

    Tom

  • Comment author was deleted

    Mar 19, 2013 @ 13:33

    Looking into it this afternoon, will report back here :)

  • Comment author was deleted

    Mar 19, 2013 @ 14:57

    Just checked and it works like expected... using latest contour

    Are you using the razor or usercontrol macro to output your form?

  • Tom Martin 30 posts 72 karma points
    Mar 19, 2013 @ 15:02
    Tom Martin
    0

    im using razor to output a custom form /Umbraco/Plugins/umbracoContour/Views/Forms/c3b23066-dd2b-4bbc-905e-9baebd3f6ffc/Form.cshtml

    @Umbraco.RenderMacro("umbracoContour.RazorRenderForm"new {FormGuid="c3b23066-dd2b-4bbc-905e-9baebd3f6ffc" })

    Specifically the code for rendering the checkboxes (as I need them rendered under a specific area) is

    <ul class="CheckContent">
                    @foreach (FieldsetViewModel fs in Model.CurrentPage.Fieldsets)
                    {
                            foreach (FieldViewModel f in fs.Fields)
                            {
                                if (f.FieldTypeName == "CheckBox")
                                { 
                                    bool hidden = f.HasCondition && f.ConditionActionType == FieldConditionActionType.Show;
                                    <li>
                                        <div class="@f.CssClass" @{if (hidden){<text> style="displaynone"</text>}}>
                                             @Html.Partial(FieldViewResolver.GetFieldView(Model.FormId, f.FieldTypeName, f.Caption), f)
                                             @if(!f.HideLabel){<label for="@f.Id" class="fieldLabel">@f.Caption @if (f.ShowIndicator){<span class="contourIndicator">@Model.Indicator</span>}</label>}
                                            
                                            @if (Model.ShowFieldValidaton){@Html.ValidationMessage(f.Id)}
                                        </div>
                                    </li>
                                }
                            }
                    }
                </ul>
  • Comment author was deleted

    Mar 19, 2013 @ 15:05

    Ok maybe try restoring the original views for a sec to see if it works in that case

     

  • Tom Martin 30 posts 72 karma points
    Mar 19, 2013 @ 15:10
    Tom Martin
    0

    Ok I reverted and still had the same issue...

  • Comment author was deleted

    Mar 19, 2013 @ 15:13

    Does it also happen when you preview the form?

  • Tom Martin 30 posts 72 karma points
    Mar 19, 2013 @ 15:17
    Tom Martin
    0

    I've reverted back to my custom form, and the preview seems to work!

  • Comment author was deleted

    Mar 19, 2013 @ 15:25

    Ok might be that the server validation is failing (so a bug) do you have the js scripts on your frontend for the validation? jquery validate, jquery validate unobtrosive?

  • Tom Martin 30 posts 72 karma points
    Mar 19, 2013 @ 15:28
    Tom Martin
    0

    Ive got the following:

    <script type="text/javascript" src="/Scripts/jquery-1.7.1.min.js"></script> 
    <script type="text/javascript" src="http://ajax.aspnetcdn.com/ajax/jquery.validate/1.8.1/jquery.validate.min.js"></script>
    <script type="text/javascript" src="http://ajax.aspnetcdn.com/ajax/mvc/3.0/jquery.unobtrusive-ajax.min.js"></script>
    <script type="text/javascript" src="http://ajax.aspnetcdn.com/ajax/mvc/3.0/jquery.validate.unobtrusive.min.js"></script>
  • Comment author was deleted

    Mar 19, 2013 @ 15:29

    Yeah those should do it

  • Tom Martin 30 posts 72 karma points
    Mar 19, 2013 @ 21:36
    Tom Martin
    0

    Hi Tim, did you find time to work out what the issue was ?

  • Comment author was deleted

    Mar 20, 2013 @ 08:21

    Hey Tom,

    Well I tested and both client and server side validation is working... and since it is working in preview mode in your case... any chance I can take a look at your site? You can mail details to tg at umbraco dot com

    Cheers,
    Tim 

Please Sign in or register to post replies

Write your reply to:

Draft