Copied to clipboard

Flag this post as spam?

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


  • Bo Kingo Damgaard 157 posts 456 karma points
    Mar 08, 2013 @ 14:54
    Bo Kingo Damgaard
    0

    Missing validation scripts when form inserted as Razor in RTE

    Hi

    When I preview a form these scripts are included in the rendered page

     

    <link type="text/css" href="css/jquery-ui-1.8.18.custom.css" rel="stylesheet" />    
    <script type="text/javascript" src="scripts/jquery-1.5.1.min.js"></script>
    <script type="text/javascript" src="scripts/jquery-ui-1.8.11.min.js"></script>
    <script type="text/javascript" src="scripts/jquery.validate.min.js"></script>
    <script type="text/javascript" src="scripts/jquery.validate.unobtrusive.min.js"></script>

     

    If I insert the form in a RTE as a Razor script, the scripts are not inserted on the page and I get an error in

    $.validator.setDefaults({})

    in contourform.js because the validator is not defined.

    Am I supposed to insert them myself? That doesn't seems logical, as I would have to insert them on every page because I don't know where the client is inserted the form.

    I'm running Umbraco 6.0.2 and Contour 3.0.9

    Kind Regards

    Bo

  • Comment author was deleted

    Mar 08, 2013 @ 15:34

    Yeah needs to be done manually

  • Comment author was deleted

    Mar 08, 2013 @ 15:35

    Or you could update the form view and place them there...

  • Bo Kingo Damgaard 157 posts 456 karma points
    Mar 08, 2013 @ 15:39
    Bo Kingo Damgaard
    0

    I'll do that, as I'm allready modifying it anyway.

    Thanks for your help.

  • Jeric 122 posts 192 karma points
    Apr 05, 2013 @ 16:25
    Jeric
    0

    How do you update them manually in the view? 

    I'm facing the same problem but can't figure out what needs to be added in the view 

  • Bo Kingo Damgaard 157 posts 456 karma points
    Apr 06, 2013 @ 10:51
    Bo Kingo Damgaard
    2

    @Jeric

    I inserted these lines:

     

    <script type="text/javascript" src="/umbraco/plugins/umbracocontour/scripts/jquery-ui-1.8.11.min.js"></script>
    <script type="text/javascript" src="/umbraco/plugins/umbracocontour/scripts/jquery.validate.min.js"></script>
    <script type="text/javascript" src="/umbraco/plugins/umbracocontour/scripts/jquery.validate.unobtrusive.min.js"></script>

    in

    /umbraco/plugins/umbracocontour/views/form.cshtml

    right after

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

    Just make sure that it doesn't collide with other scripts on that page, ie jquery

    /Bo

     

  • Jeric 122 posts 192 karma points
    Apr 07, 2013 @ 00:11
    Jeric
    0

    Thanks Kingo, I'll try it out.

    /Jeric 

  • Jeric 122 posts 192 karma points
    Apr 08, 2013 @ 11:22
    Jeric
    0

    Hi Bo,

    I've tried that, and the below error came out

    Uncaught ReferenceError: jQuery is not defined contourform.js:54 (which is the last line as below)

     

    varcontourFieldValues;
    (function($){
    $.validator.setDefaults({
    ignore:":hidden"
    });
     
    $.validator.unobtrusive.adapters.addBool("requiredcb","required");
    $.validator.addMethod('contour_selectonefromlist',function(value,element){
    varvalid=false;
    $("input",$(element).parent()).each(function(i){
    if($(this).is(':checked')){valid=true;}
    });
    returnvalid;
    });
    $.validator.unobtrusive.adapters.addBool("requiredlist","contour_selectonefromlist");
    $.validator.addMethod('contour_regex',function(value,element){
    varregex=$(element).attr("data-regex");
    varval=$(element).val();
    if(val.length==0){returntrue;}
    returnval.match(regex);
    });
    $.validator.unobtrusive.adapters.addBool("regex","contour_regex");
    $(function(){
    $("#PreviousClicked").val("");
     
    $(".datepickerfield").datepicker({dateFormat:contourDateFormat});
     
    $(".cancel").click(function(){
    $("#PreviousClicked").val("clicked");
    });
     
    $(".contourPage input").change(function(){
    PopulateFieldValues();
    CheckRules();
    });
     
    $(".contourPage select").change(function(){
    PopulateFieldValues();
    CheckRules();
    });
     
    PopulateFieldValues();
    CheckRules();
    });
     
    }(jQuery));

     

  • Jeric 122 posts 192 karma points
    Apr 08, 2013 @ 15:35
    Jeric
    0

    Hi Bo,

    Found the errors and fixed it. THanks for the help :)

  • Halle 9 posts 59 karma points
    Apr 30, 2013 @ 13:25
    Halle
    0

    Hi Jeric,

    What errors did you find? I'm currently having the exact same problem.

    Thanks in advance!

    /Hampus

  • Jeric 122 posts 192 karma points
    May 01, 2013 @ 11:42
    Jeric
    0

    Hi (Halle), Mine was caused by other API that i'm using which strips out the validation bit

  • This forum is in read-only mode while we transition to the new forum.

    You can continue this topic on the new forum by tapping the "Continue discussion" link below.

Please Sign in or register to post replies