Inline Validator

In non-as-you-type spell checking scenarios it may be desirable to have the inline spell checker work as a validator. This can be configured with asp:CustomValidator as a client script validator.

Static mode validation

  1. Setup static mode checking per this topic.
  2. Add the validation function to a Javascript block.
    function validateSpelling(oSrc, args) {
    	//Check if spell check already ran.
    	for (var i = 0; i < rsw_scs.length; i++) {
    		if (rsw_scs[i].textBoxID == oSrc.controltovalidate && rsw_scs[i].hasRun) {
    			args.IsValid = true;
    			return;
    		}
    	}
    
    	var rapidSpellChecker = new RapidSpellCheckerClient(rapidSpell.ayt_helperURL);
    	rapidSpellChecker.config = rsw_getConfigurationObject('default');
    	var result = rapidSpellChecker.Check(args.Value);
    	args.IsValid = result.numberOfErrors == 0;
    }
    

    This will check if spell checking has been performed on the text box that is validating, and if not will check it for errors using the RapidSpellCheckerClient class.
  3. Add an asp:CustomValidator to the page for each text box.
    <asp:CustomValidator id="CustomValidator1"  runat="server" ControlToValidate="TextBox1" EnableClientScript='true' 
                 ErrorMessage="There are spelling errors and spell check hasn't been performed." 
                 ClientValidationFunction="validateSpelling">
                </asp:CustomValidator>
    
  4. Tip: it appears that generally (with or without RapidSpell) the .NET CustomValidator, when using a ClientValidationFunction, does not work in strict page mode (i.e.<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">) - please do conduct your own tests.