JQuery: Get Rid off SharePoint Spell Check

Hi Guys,

After spending 3-4 hours of struggle, I finally found way to get rid off irritating SharePoint Spell checker. It caught people picker too under the umbrella of spell check, but why, usually it does not required. Well again it may be the requirement.

But for my case, I don't want it to watch any of my control on whole site. I tried to navigate to Manage Farm Features > Spell Check feature. Even after deactivating this feature it still working like a stubborn functionality. Then I realized that nothing is impossible for a developer. I have JQuery with me I can hide that control.

Resolution:

1) Hiding spell check from the Ribbon: in order to hide the spell check feature to end user, trick that worked for me is to add following line in my custom js:

$('a:has(img[src*="images/spellingHH.png"])').parents("li").hide();

2) Exclude fields from the spell check feature: I have created follwoing method to exclude people picker and other inputs fields from spell check:

function DisableSpellCheck() {
var tagclass = $("input").attr('class');
if (tagclass !== undefined) {
tagclass = tagclass.replace(' ms-spellcheck-true', '');
}
$(".input").attr('class', tagclass);

var $fld_in = $("div.authorEdit input");
var $fld_tx = document.getElementsByTagName('textarea');

for ($i = 0; $i < $fld_in.length; $i++) {
var $inputName = $fld_in[$i].getAttribute('name');
if ($inputName.indexOf('UserField') != -1) {
$fld_in[$i].className = 'ms-spellcheck-false';
}
}
for ($i = 0; $i < $fld_tx.length; $i++) {
var $inputName = $fld_tx[$i].getAttribute('name');
if ($inputName.indexOf('UserField') != -1) {
$fld_tx[$i].setAttribute("excludeFromSpellCheck", "true");
}
}
}

Note: "authorEdit" is the custom class added to the people picker.

If you add this line of code to your master page or document.ready function of the page layout it will solve this issue.

Hope this little trick might helpful.

Happy SharePointing :)!!

Comments

Popular posts from this blog

Hide Ribbon on SharePoint 2013 using CSS

Get Comment Count in SharePoint

Configure external site as content sources in sharepoint search