Copied to clipboard

Flag this post as spam?

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


  • Bex 444 posts 555 karma points
    Sep 08, 2011 @ 15:11
    Bex
    0

    How do I add a validation group to UComment?

    Hi!

    I have Ucomment on a page and I also have another form to submit and email address for a news letter.

    My Newsletter submit has its own standard .net required field validator and I have set the validation group of the validator and button.

    My problem is my news letter button is also firing the validation of UComment so my newsletter won't submit.

    Can I get round this by somehow adding a validation group?

    Bex

  • Bex 444 posts 555 karma points
    Sep 08, 2011 @ 15:16
    Bex
    0

    Have worked out what I need to do.

    The problem was that any submit button on the page was causing validation and submitting my comments.

    I have made a slight tweak to the UCommentForm usercontrol.

    I have updated the validation scrip in the jQuery so that the validate function is performed within the click event of the button. So it now reads:

    $("#submitButton").click(function(){
    jQuery("#frmComment").validate({
              submitHandler: function(form) {
       jQuery("#commentform").hide();
       jQuery("#commentLoading").show();
       jQuery("#commentform #submit").attr("enabled", false);    
        var url = "/base/UComment/CreateComment/<umbraco:Item field="pageID" runat="server"/>.aspx";  
    jQuery.post(url, { author: jQuery("#commentform #author").val(), email: jQuery("#commentform #email").val(), url: jQuery("#commentform #url").val(), comment: jQuery("#commentform #comment").val() },
                       function(data){                   
                       jQuery("#commentLoading").hide();
                       jQuery("#commentPosted").show().removeClass("error");                 
                        if(data == 0){
                              jQuery("#commentPosted").addClass("error").html(" <%= XsltLibrary.Dictionary("#CommentFailend","Your comment could not be posted, we're very sorry for the inconvenience") %> ");
                              jQuery("#commentform").show();
                              jQuery("#commentform #submit").attr("enabled", true);
                        }                 
    });
    }
    });
    });
  • 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