More in this section

Forums / Developing with Sitefinity / Problem with RadEditor Validation

Problem with RadEditor Validation

15 posts, 2 answered
  1. Nisha
    Nisha avatar
    17 posts
    Registered:
    17 Jun 2009
    29 Jul 2009
    Link to this post
    Hi,
        I am using a RadEditor control in CommentList.ascx page in News section. Which uses the

    RequiredFieldValidator control for validation. When i click on the submit button, it dosen't give any error message while on the same page RequiredFieldValidator is used for 'Name' field and RegularExpressionValidator is used for 'Email' field, and  both are working fine.

    The code  used is :

     

                    <telerik:RadEditor   
                                runat="server"   
                                ID="commentTxt1" 
                                ToolsFile="~/Sitefinity/ControlTemplates/Blogs/ToolsFile.xml" 
                                EnableEmbeddedSkins="True"   
                                Skin="Default"   
                                Width="100%" 
                                EditModes="Design">    
                     </telerik:RadEditor>     
                     <asp:RequiredFieldValidator runat="server" ID="RequiredFieldValidator1"   
                            ControlToValidate="commentTxt1" 
                            ErrorMessage="Comment valid"   
                            Display="dynamic"   
                            ValidationGroup="commentInfo" 
                            CssClass="sf_commentsValidator">  
                            <strong>Message text is required</strong> 
                     </asp:RequiredFieldValidator>    

     

    I am not getting where is the problem. Pls help.
    Waiting for reply.

    Thank you,
    Nisha

     

     

     

     

     

  2. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    12 Sep 2017
    29 Jul 2009
    Link to this post
    Hello Nisha,

    Please change the ID of the RequiredFieldValidator control as below:

           <asp:RequiredFieldValidator runat="server" ID="contentVal"  
                        ControlToValidate="commentTxt" 
                        ErrorMessage="<%$Resources:CommentEmpty %>"  
                        Display="dynamic"  
                        ValidationGroup="commentInfo" 
                        CssClass="sf_commentsValidator"
                        <strong>Message text is required</strong> 
                 </asp:RequiredFieldValidator>   

    All the best,
    Ivan Dimitrov
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Check out the tips for optimizing your support resource searches.
    Answered
  3. Nisha
    Nisha avatar
    17 posts
    Registered:
    17 Jun 2009
    30 Jul 2009
    Link to this post
    Hi Ivan,
        Thank you. Its working....

    Nisha
  4. Nisha
    Nisha avatar
    17 posts
    Registered:
    17 Jun 2009
    30 Jul 2009
    Link to this post
    Hi Ivan,
     Now I want to validate other fields on the same page with RegularExpressionValidator as :
            1 . Name - already have validator RequiredFieldValidator with ID 'authorVal' , I want to validate same field for "no special characters allowed except space and ' " . also i want "no spaces at the start" for the Name field.
            2. WebSite  - it doesent have any validator, I want to validate it with proper URL format....

     I applied  RegularExpressionValidator to both the fields , it gives proper message when click on the submit button first time. but without changing any field values if i clicked again , it gets submitted.

    Only the validators that are on the page comes by defaultly are working fine, but the newly added controls not working properly....

    How can i solve this problem?

    Thanks in advanced...
    Nisha
  5. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    12 Sep 2017
    30 Jul 2009
    Link to this post
    Hi Nisha,

    Can you send me the declaration of the filters you are applying so I can see what is going wrong.

    Regards,
    Ivan Dimitrov
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Check out the tips for optimizing your support resource searches.
  6. Nisha
    Nisha avatar
    17 posts
    Registered:
    17 Jun 2009
    30 Jul 2009
    Link to this post
    Hi Ivan
        Declaration for the Name fileds filter is as follow:
    <asp:TextBox ID="authorTxt" runat="server" MaxLength="50" size="30" CssClass="inputbox01"></asp:TextBox> 
    <asp:RequiredFieldValidator runat="server" 
        ID="authorVal"  
        ControlToValidate="authorTxt" 
        ErrorMessage="<em>Name</em> can't be empty!" 
        Display="dynamic" 
        
    CssClass="commentsValidator">
    </asp:RequiredFieldValidator> 
    <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> 
     

    And Declaration for the WebSite filter is :
     <asp:TextBox ID="webSiteTxt" runat="server" size="30" MaxLength="50" CssClass="inputbox01"></asp:TextBox> 
    <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> 
                        

  7. Nisha
    Nisha avatar
    17 posts
    Registered:
    17 Jun 2009
    04 Aug 2009
    Link to this post
    I am stucked at this point. pls give me the solution....
  8. Georgi
    Georgi avatar
    3583 posts
    Registered:
    28 Oct 2016
    04 Aug 2009
    Link to this post
    Hello Nisha,

    Looking in the Validators, I see that in this case you are using regular asp.net checkboxes. IN this case, the validators should point the exact ID of the checkboxes, rather than placing IdVal (with Val) in the end. I think this is the problem.

    Best wishes,
    Georgi
    the Telerik team

    Instantly find answers to your questions on the newTelerik Support Portal.
    Check out the tipsfor optimizing your support resource searches.
  9. Nisha
    Nisha avatar
    17 posts
    Registered:
    17 Jun 2009
    05 Aug 2009
    Link to this post
    HI Georgi ,
        thanks for the reply. I tried by changing the ID of the validators (removing Val at the end) but it doesnt work.
    I am using the Regular Expression validators for the 'Name' and 'Website' textboxes which are in CommentsList.ascx page.(and not the checkboxes)
        My problem is validators that are already in the page are working fine but the extra validators that i have applied to above textboxes are not working. It displays the error message first time, but if i click again on the 'Post the Comment' button it gets submitted.
        Pls read the thread from start, where i mention the details about related  IDs and code so that u can get idea about what may problem exactly is.
        Waiting for reply.

    Thank you.
    - Nisha
  10. Radoslav Georgiev
    Radoslav Georgiev avatar
    3370 posts
    Registered:
    01 Feb 2016
    07 Aug 2009
    Link to this post
    Hello Nisha,

    Did you take a look at the Validation controls in news comments. The thread describes the same problem as yours and provides a solution.

    Can you give the solution there a try and come back to us with the results..

    Greetings,
    Rado
    the Telerik team

    Instantly find answers to your questions on the newTelerik Support Portal.
    Check out the tipsfor optimizing your support resource searches.
    Answered
  11. Nisha
    Nisha avatar
    17 posts
    Registered:
    17 Jun 2009
    07 Aug 2009
    Link to this post
    hi
    i read that thread, and i got the solution.
    Thank you very much
    -nisha.
  12. Nisha
    Nisha avatar
    17 posts
    Registered:
    17 Jun 2009
    11 Aug 2009
    Link to this post
    hi
     I want to do some extra validations on RAD editor control other than blank check. I applied RegularExpresionValidator to validate the editor control. But its not working.If i apply same validator for name textbox control , its working properly. Then what is the problem with Rad editor?
    Pls reply.

    Thanks
    Nisha
  13. Radoslav Georgiev
    Radoslav Georgiev avatar
    3370 posts
    Registered:
    01 Feb 2016
    13 Aug 2009
    Link to this post
    Hi Nisha,

    Validating the content itself is a little bit tricky. Asp regular expression validators cannot work flawlessly with the RadEditor. So in that case you can do the following. Add a hidden text box to the markup of your comments list control, this textbox will simply take the text from the RadEditor.. Make the regular expression validate the text of the text box on click of the submit button. Here is an example how to do this:
    <asp:Button ID="submitBtn"  OnClick="OnClick" runat="server" Text="<%$Resources:PostThisComment %>" CssClass="commentsButton" /> 
    <asp:TextBox visible="false" runat="server" Text="" ID="editorText" /> 

    This adds the OnClick event and the hidden textbox. Make sure you point the regex validator to validate the "editorText" control Now just add the logic to handle this:
    protected void OnClick(object sender, EventArgs e) 
       { 
           this.editorText.Text = this.commentTxt.Text; 
           this.EditorTextRegExValidator.Validate(); 
       } 

    This should do the trick.

    Sincerely yours,
    Rado
    the Telerik team

    Instantly find answers to your questions on the newTelerik Support Portal.
    Check out the tipsfor optimizing your support resource searches.
  14. Nisha
    Nisha avatar
    17 posts
    Registered:
    17 Jun 2009
    14 Aug 2009
    Link to this post
    hi Rado,
        Thanks for the reply. I have tried the solution u provided. but its not working as per the requirement. I have applied the RegularExpression validator and check for the 'blank spaces at the start' validation for Comment textbox, but it shows me the error message everytime when i click the button.and dosent save the comment.
    Waiting for the reply.

    Thnk you.
    Nisha
  15. Radoslav Georgiev
    Radoslav Georgiev avatar
    3370 posts
    Registered:
    01 Feb 2016
    17 Aug 2009
    Link to this post
    Hello Nisha,

    Thank you for getting back to me.

    I have looked again at the code I sent you and found my error. Instead of assigning, the RadEditor.Text to the hidden text box, you should assign the RadEditor.Content. This is so because the editor Text property of returns editor content as pure text and the, and the regular expression validation always fails. Now when you get the text using the Content property you will get the text in the format as it should be taken from the textbox and therefore the reg ex validator should wok. I have tested it couple of times on my end, and it works as it should.

    Here is how the revised OnClick event should look:
    protected void OnClick(object sender, EventArgs e) 
         { 
             this.editorText.Text = this.commentTxt.Content
             this.commentTxtVal.Validate(); 
         }  

    Please, give this a try and see how it works. If you have more questions, please feel free to contact  us.

    Kind regards,
    Rado
    the Telerik team

    Instantly find answers to your questions on the newTelerik Support Portal.
    Check out the tipsfor optimizing your support resource searches.
Register for webinar
15 posts, 2 answered