+1-888-365-2779
Try Now
More in this section

Forums / Developing with Sitefinity / Forum Captcha - How to post?

Forum Captcha - How to post?

4 posts, 0 answered
  1. Brad
    Brad avatar
    28 posts
    Registered:
    20 Sep 2010
    24 Nov 2010
    Link to this post
    Hi,

    We have implemented a CAPTCHA system on the forum EditPost.ascx file, but we can not find a way to prevent the post from still "posting" itself even if the captcha is bad. If the captcha is correct, it posts, but even if the captcha is not correct, the post still goes through. Is there any way to prevent the data from posting if the Captcha is incorrect? Code is simply:

    protected void saveButton_Click(object sender, EventArgs e)
        {  
            recaptcha.Validate();
     
            if (recaptcha.IsValid)
            {
                using (com.cdyne.ws.ProfanitySoapClient client = new com.cdyne.ws.ProfanitySoapClient("ProfanitySoap"))
                {
                    //check the quote textbox for bad words...
                    com.cdyne.ws.FilterReturn ret = client.SimpleProfanityFilter(tbQuote.Content);
     
                    if (ret.FoundProfanity)
                    {
                        tbQuote.Content = ret.CleanText;
                    }
     
                    //check the editor textbox for bad words
                    ret = client.SimpleProfanityFilter(editor.Content);
     
                    if (ret.FoundProfanity)
                    {
                        editor.Content = ret.CleanText;
                    }
                }
            }
        }

    Thanks in advance,
    Brad
  2. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    09 Dec 2016
    24 Nov 2010
    Link to this post
    Hello Brad,

    You have to check whether the page is valid -  if (Page.IsValid)

    All the best,
    Ivan Dimitrov
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
  3. Brad
    Brad avatar
    28 posts
    Registered:
    20 Sep 2010
    25 Nov 2010
    Link to this post
    Hi Ivan,

    Thank you for the quick response. I've added an IsValid check, but to no avail. New code:

    protected void saveButton_Click(object sender, EventArgs e)
        {
            Page.Validate();
            if (Page.IsValid)
            {
                recaptcha.Validate();
                if (recaptcha.IsValid)
                {
                    using (com.cdyne.ws.ProfanitySoapClient client = new com.cdyne.ws.ProfanitySoapClient("ProfanitySoap"))
                    {
                        //check the quote textbox for bad words...
                        com.cdyne.ws.FilterReturn ret = client.SimpleProfanityFilter(tbThreadTitle.Text);
     
                        if (ret.FoundProfanity)
                        {
                            tbThreadTitle.Text = ret.CleanText;
                        }
     
                        //check the editor textbox for bad words
                        ret = client.SimpleProfanityFilter(editor.Content);
     
                        if (ret.FoundProfanity)
                        {
                            editor.Content = ret.CleanText;
                        }
                    }
                }
            }
        }

    We have no doubt that this does in fact check, but there's no "Else it shouldn't post" method that we can locate?
  4. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    09 Dec 2016
    25 Nov 2010
    Link to this post
    Hi Brad,

    If the page is not valid this code should not be executed. The Page.IsValid property indicates whether page validation has succeeded. For this property to return true, all validation server controls in the Page.Validators property must validate successfully.

    You can actually check this demo.

    Kind regards,
    Ivan Dimitrov
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
Register for webinar
4 posts, 0 answered