How to supress RadSpell when all words are spelt correctly?

9 posts, 0 answers
  1. taeho
    taeho avatar
    29 posts
    Member since:
    Mar 2008

    Posted 11 Nov 2008 Link to this post

    Thanks for your support first of all,

    I have a textbox to check, the textbox has onBlur="GetRadSpell(spellCheckClientId).startSpellCheck();"
    Now if Sydney (which is correct) is typed and go to the next input box, I don't want to display radSpell windows.
    But when Sydny is typed then the windows should appear to allow users to be aware.

    Is that possible?

    Thanks

    Toby
  2. Rumen
    Admin
    Rumen avatar
    12848 posts

    Posted 14 Nov 2008 Link to this post

    Hi Toby,

    I think that the following KB article could be helpful for your scenario: Using SpellCheckService to derermine if there are mistakes in the editor's content.

    Best regards,
    Rumen
    the Telerik team

    Check out Telerik Trainer, the state of the art learning tool for Telerik products.
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. taeho
    taeho avatar
    29 posts
    Member since:
    Mar 2008

    Posted 16 Nov 2008 Link to this post

    Thank you for your answer.
    I read the article and followed it but I am getting some problems.
    I gathered that I need to use SpellCheckService.
    I am using
    Runtime version v2.0.50727
    Version 2008.3.1105.20

    But having problem registering SpellCheckService.
    I did

    <%@ Register TagPrefix="rad" Namespace="Telerik.WebControls" Assembly="RadSpell" %>
    Or
    <%@ Register TagPrefix="rad" Namespace="Telerik.Web.UI" Assembly="RadSpell" %>
    OR
    <%@ Register TagPrefix="rad" Namespace="Telerik.WebControls" Assembly="Telerik.WebControls" %>
    OR
    <%@ Register TagPrefix="rad" Namespace="Telerik.Web.UI" Assembly="Telerik.Web.UI" %>

    <rad:SpellCheckService id="SpellCheckService1" runat="server"></rad:SpellCheckService>

    It is saying SpellCheckService is not known element.

    Could you please help???

    Thanks





  5. Rumen
    Admin
    Rumen avatar
    12848 posts

    Posted 20 Nov 2008 Link to this post

    Hi Taeho,

    For your convenience, I created and attached a sample fully working project that demonstrates the solution provided in the KB article.


    Kind regards,
    Rumen
    the Telerik team

    Check out Telerik Trainer, the state of the art learning tool for Telerik products.
  6. taeho
    taeho avatar
    29 posts
    Member since:
    Mar 2008

    Posted 20 Nov 2008 Link to this post

    Hi thanks for your reply.
    However, I am using a normal textbox and radSpell control attached to it.

    Thanks
  7. Rumen
    Admin
    Rumen avatar
    12848 posts

    Posted 25 Nov 2008 Link to this post

    Hi Taeho,

    You can use the RadEditor control and its ajax spellchecking engine to achieve your scenario. Here is some sample code:

    <script type="text/javascript"
    var spellService = null
    function checkWord(word) 
        if (!spellService) 
        { 
            spellService = $find("<%= spellEditor.ClientID %>").get_spellCheckService(); 
            spellService.add_complete(spellCallback); 
        } 
        spellService.spellCheck(word); 
    function spellCallback(sender, args) 
        if (args.badWords.length > 0) 
        { 
            var badWord = args.badWords[0]; 
            var suggestions = badWord.suggestionsString; 
            // suggestions now holds an array of possible spellings for the misspelled word 
        } 
    </script> 
    <input type="button" id="launchButton1" value="Spell Check" onclick="javascript:checkWord('teszt');" /><br /> 
    <div style="display:none"
    <telerik:RadEditor ID="spellEditor" runat="server"
    <Tools><telerik:EditorToolGroup><telerik:EditorTool Name="ajaxspellcheck" /></telerik:EditorToolGroup></Tools></telerik:RadEditor> 
    </div> 

    As you can see, I use a hidden RadEditor control with just the AjaxSpellCheck tool. The checkWord() function initiates an ajax request for the word you wish to check and the response is handled by the spellCallback() function. If the word was not in the spell check dictionary, the suggestions varialbe will hold an array of suggestions you can use in your search dropdown.



    Best regards,
    Rumen
    the Telerik team

    Check out Telerik Trainer, the state of the art learning tool for Telerik products.
  8. burn
    burn avatar
    4 posts
    Member since:
    Nov 2006

    Posted 19 Jan 2009 Link to this post

    Hello,

    I am using the suggested SpellCheckService method (see below), and it's working great.

    Is it possible to retrieve the id of the html element being spellchecked? (In my case a hidden input field from the callback function)
    Something like

    spellcallback(sender, args, id); 


    I have multiple hidden input fields that I'm checking for spelling errors and would like to know which fileds failed and which passed. As the callbacks are assynch I can't rely on the order of the callback.

    TIA,

    Anders

    <script type="text/javascript">    
    var spellService = null;    
    function checkWord(word)    
    {    
        if (!spellService)    
        {    
            spellService = $find("<%= spellEditor.ClientID %>").get_spellCheckService();    
            spellService.add_complete(spellCallback);    
        }    
        spellService.spellCheck(word);    
    }    
    function spellCallback(sender, args)    
    {    
        if (args.badWords.length > 0)    
        {    
            var badWord = args.badWords[0];    
            var suggestions = badWord.suggestionsString;    
            // suggestions now holds an array of possible spellings for the misspelled word    
        }    
    }    
    </script>    
    <input type="button" id="launchButton1" value="Spell Check" onclick="javascript:checkWord('teszt');" /><br />    
    <div style="display:none">    
    <telerik:RadEditor ID="spellEditor" runat="server">    
    <Tools><telerik:EditorToolGroup><telerik:EditorTool Name="ajaxspellcheck" /></telerik:EditorToolGroup></Tools></telerik:RadEditor>    
    </div>    
     
  9. Rumen
    Admin
    Rumen avatar
    12848 posts

    Posted 20 Jan 2009 Link to this post

    Hi burn,

    Please, find below a sample code example which demonstrates how to pop up a message which fields contains errors:

    <script type="text/javascript">  
    var spellService = null;  
    var currentIndex = 0
    var fieldsWithErrors = []; 
    var fields = []; 
     
    function checkFields()  
    {      
        //Set which elements should be checked 
        fields = ["field1", "field2", "field3", "field4"]; 
         
        //Initialize spellcheck 
        if (!spellService)  
        {  
            spellService = $find("<%= spellEditor.ClientID %>").get_spellCheckService();  
            spellService.add_complete(spellCallback);  
        }  
             
        //Get text 
        var text = $get(fields[currentIndex]).value; 
        spellService.spellCheck(text);  
    }  
     
     
    function spellCallback(sender, args)  
    {  
        if (args.badWords.length > 0)  
        {  
            var badWord = args.badWords[0];  
            var suggestions = badWord.suggestionsString;  
            //suggestions now holds an array of possible spellings for the misspelled word  
             
            //Add this element to the bad words array 
            fieldsWithErrors[fieldsWithErrors.length] = fields[currentIndex];                 
        }  
         
        //Increase counter 
        currentIndex++; 
             
        //If currentIndex < fields.length - go on 
        if (currentIndex < fields.length
        {                 
            var text = $get(fields[currentIndex]).value; 
            spellService.spellCheck(text);  
        } 
        else //Display results 
        { 
            alert("There are errors in " + fieldsWithErrors); 
         
            //Reset variables for next spellcheck run 
            currentIndex = 0
            fieldsWithErrors  = []; 
        } 
             
    }  
    </script>  
     
    <input type="button" id="launchButton1" value="Spell Check" onclick="javascript:checkFields();return false;" /><br />  
     
    <textarea id="field1"> This text is correct</textarea> 
     
    <textarea id="field2"> Thiz tekst is rong</textarea> 
     
    <textarea id="field3"> This text is correct</textarea> 
     
    <textarea id="field4"> Thiz tekst is rong</textarea> 
    <div style="display:none">  
    <telerik:RadEditor ID="spellEditor" runat="server">  
    <Tools><telerik:EditorToolGroup><telerik:EditorTool Name="ajaxspellcheck" /></telerik:EditorToolGroup></Tools></telerik:RadEditor>  

    For your convenience I have attached my test page.

    Feel free to enhance the code to fit your specific scenario.

    Regards,
    Rumen
    the Telerik team

    Check out Telerik Trainer, the state of the art learning tool for Telerik products.
  10. burn
    burn avatar
    4 posts
    Member since:
    Nov 2006

    Posted 20 Jan 2009 Link to this post

    Again the Telerik Team comes through. Thank you for the code snippet works to perfection.

    Anders.
Back to Top
UI for ASP.NET Ajax is Ready for VS 2017