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

Forums / Bugs & Issues / Validation controls in news comments

Validation controls in news comments

5 posts, 0 answered
  1. shraddha
    shraddha avatar
    87 posts
    Registered:
    18 May 2009
    31 Jul 2009
    Link to this post
    Hi,
    I am using News Comments module. in that module I want to add some more validation control. e.g. for checking special characters in Name field.. etc.
    I have added the validation controls for the same, but when i enter any non-required special character in the textbox, it shows error mesage and submits the page. How do I handle this??
    Please help...

    Thanx..
  2. Georgi
    Georgi avatar
    3583 posts
    Registered:
    28 Oct 2016
    31 Jul 2009
    Link to this post
    Hello shraddha,

    Can you show us the error that you get, as well as the validators? I am not sure what rules you have used and what the error is.
    Thank you in advance.

    All the best,
    Georgi
    the Telerik team

    Instantly find answers to your questions on the newTelerik Support Portal.
    Check out the tipsfor optimizing your support resource searches.
  3. shraddha
    shraddha avatar
    87 posts
    Registered:
    18 May 2009
    03 Aug 2009
    Link to this post
    Hi Georgi,

    <asp:RegularExpressionValidator runat="server" ID="authorValSpChar" ControlToValidate="authorTxt" 
                                ValidationExpression="^[^\s][a-zA-Z'.\s]{1,40}$" ErrorMessage="Name should not have special characters or numbers other than [space,',.] symbols !" 
                                Display="dynamic" CssClass="commentsValidator"></asp:RegularExpressionValidator> 
     
     
    <asp:RegularExpressionValidator runat="server" ID="webSiteVal" ControlToValidate="webSiteTxt" 
                                ValidationExpression="^(ht|f)tp(s?)\:\/\/[0-9a-zA-Z]([-.\w]*[0-9a-zA-Z])*(:(0-9)*)*(\/?)([a-zA-Z0-9\-\.\?\,\'\/\\\+&amp;%\$#_]*)?$" 
                                ErrorMessage="Invalid <em>URL</em>!" Display="dynamic" CssClass="commentsValidator"></asp:RegularExpressionValidator> 


    Above given are the two extra validations that we are using. both are showing the mentioned error messages if wrong value is given, but submits the page after that.

    Thanx
  4. Georgi
    Georgi avatar
    3583 posts
    Registered:
    28 Oct 2016
    06 Aug 2009
    Link to this post
    Hello shraddha,

    I see what is the problem now.

    We are assigning unique validation groups to the comments list, because you could have more than one comments lists control on the same page. This way, your validators does not have the same validation group.

    Here is the workaround. 

    Create a code behind file of the CommentsList.ascx :

    using System; 
    using System.Collections.Generic; 
    using System.Linq; 
    using System.Web; 
    using System.Web.UI; 
    using System.Web.UI.WebControls; 
    using Telerik.Cms.Engine.WebControls; 
     
    public partial class Sitefinity_ControlTemplates_Generic_Content_CommentsList : System.Web.UI.UserControl 
        protected void Page_Load(object sender, EventArgs e) 
        { 
     
        } 
        protected override void OnPreRender(EventArgs e) 
        { 
            base.OnPreRender(e); 
            CommentsList commentsList = this.Parent.Parent as CommentsList; 
     
            this.webSiteVal.ValidationGroup = commentsList.ValidationGroup; 
            this.authorValSpChar.ValidationGroup = commentsList.ValidationGroup; 
        } 
     

    Here's how to register the code behind:
    <%@ Control Language="C#" AutoEventWireup="true" CodeFile="CommentsList.ascx.cs" Inherits="Sitefinity_ControlTemplates_Generic_Content_CommentsList" %> 

    We will surely improve this. 

    Sincerely yours,
    Georgi
    the Telerik team

    Instantly find answers to your questions on the newTelerik Support Portal.
    Check out the tipsfor optimizing your support resource searches.
  5. shraddha
    shraddha avatar
    87 posts
    Registered:
    18 May 2009
    06 Aug 2009
    Link to this post
    Hi Georgi,
    It's working now.. Thnx..
    Now I want to add validations to Comment box for
    1. Not contain space at the start and
    2. Not contain some special characters.
    Can I do this???
    Same is working for NameTextbox but not for Comment-RadEditor.
    Please help.



    Thanx...
    Shraddha
Register for webinar
5 posts, 0 answered