Website Content Validation

By bits4bytes

The R.A.D Spellchecker Control

The usefulness, implementation and customization of the spell check dot net control. To be used for web content validation and filtering.

Background

With the evolution of programming and reusable controls the validation of web based input fields has become easier.

In order to ensure the integrity of content entered into fields of a website a control is required that evaluates input as either acceptable or not, thereafter prompting the user to rectify the input to conform to the allowed format.

This behavior is obtained in the form of programmable controls that evaluate the fields as needed. Thus ensuring the systems integrity of your solution, to a secure level of prevention against malicious intent.

This article will deal with content integrity instead, concentrating on the textual value of the messages passed on to the system, taking for granted that the integrity of the system has been adequately catered for.

Spelling

Spellchecking a field brings a lot of benefits with it, some for which an explanation follows:

  • The visible layer or content of your solution can be managed. Since this is what the user sees, the perception of the user reading the content will determine if the user would like to visit the page again.
  • Preventing unwanted words   would enhance the users experience of the site visited. This includes swear words, offensive term etcetera.
  • New types of languages emerged, for instance Internet Relay Clients (IRC), or mobile phone short messages (SMS). These became a preference for communication and more evident in the younger generation. On occasion even used to answer exam questions, and for filling out other lesser important forms!
  • Determining whether a language is relevant to your content, and the validation thereof, thus becomes apparent.
  • In some instances the moderators’ workload is decreased by passing and automating some of the validation to the source of origin. In the long run this might discourage or encourage selective groups of users using your solution.
  • Depending on the strategy chosen for user acceptance and the type of user that you would retain, careful consideration will be needed.
  • Lastly, for the sake of language correctness and subsequent unpreventable spelling mistakes, the spellchecker has definite value to add to any solution.

The R.A.D.Spell control from Telerik

The hunt for a solution abruptly ended with a trail download from http://www.telerik.com

Armed with a bunch of examples with code included in a single download, I settled down and thoroughly grilled the newly found control.

It was so easy and intuitive that I quickly ended up with the ‘whats new’ example as a template to work from.

A second visit to the telerik website provided me with a localized dictionary, that I am convinced was not available the first time around. These guys don’t miss much when it comes to client relations.

Integration with DotNetNuke

DotNetNuke is an open source framework http://www.dotnetnuke.com.
To integrate this valuable control into your solution was a simple cut and paste. The lines needed were:

<%@ Register TagPrefix=”radS” Namespace=”Telerik.WebControls” Assembly=”RadSpell.Net2″ %>

<asp:TextBox ID=”textBox1″ Runat=”server” Rows=”5″ Columns=”50″ TextMode=”MultiLine” onchange=”textChanged()”>Muy namw iz John and I cannod spella at all.  You can reach me at john@johnsdomain.com</asp:TextBox>

<radS:RadSpell ID=”spell1″ Runat=”server” ControlToCheck=”textBox1″ ButtonCssClass=”Button” OnClientCheckCancelled=”spellCancelled”/>

<radS:SpellCheckValidator ControlToValidate=”spell1″ runat=”server” ErrorMessage=”Please spell check before saving” Display=”Static” EnableClientScript=”True” id=SpellCheckValidator1 />

<asp:ValidationSummary ID=”summary” Runat=”server”/>

function textChanged()
{
 spell().setSpellChecked(false);
}

A more elegant and easier method would be to create a dnn:Spellcheck user control imbedding the R.A.D.Spell control inside and exposing its properties. Using the visual studio collection editor in the perceived dnn:Spellcheck  property box  to add the controls that should be validated. Instances of dnn:Spellcheck can then be drag and dropped from the toolbox into modules that require them and the input fields linked.
 

Alterations / Tweak

Since I opted for a single language and a high level of validation at the source of input ( the user), the only other tweak I had to implement was how to prevent the user of bypassing the spellchecker by ignoring words or canceling the spellcheck entirely. A behaviour that would make the spellchecker somewhat redundand.

So I had to ignore the ignore and cancel functions. Yet again this only involved deleting the event handlers for the buttons thus rendering it useless. And renaming the buttons to something equally useless, since deleting or disabling them caused unwanted results.

This resulted in a mode where the user has to either manually enter an alternative word for one not found in the dictionary, or to select a alternative from the list of suggested words. This has to be done until all mistakes has been modified where after the dialog box closes by default and the control is validated as successful.

When text is altered in an input field after the control has been spellchecked, the on change client side script event of the input field resets the flag resulting in the field being validated again.

Conclusion

The R.A.D.Spell control from telerik is easy to integrate, supported with adequate and superb help and tutorials. Added value is obtained with multiple dictionary formats. In short a complete spell check solution and a candidate for encapsulation and inclusion into the dotnetnuke and dotnet framework.

Leave a Reply