Disable spell check for People Picker
People picker control just contains login names and it should not be checked for spellings but SharePoint does it. Practically it is not acceptable so we have to restrict this. I have written small javascript code to inject this.
In OOB we have one property (excludeFromSpellCheck) to avoid spell check for specific controls. But by default it will not work for people picker control because it is collection of input controls. If you inspect the control using IE developer toolbar you can find the login details hold by textarea field. So using following script I am setting above property to avoid spell check.
<script type="text/javascript">
_spBodyOnLoadFunctionNames.push("disableSpellCheckOnPeoplePickers");
function disableSpellCheckOnPeoplePickers() {
var inputs = document.getElementsByTagName('TextArea');
for (var index = 0; index < inputs.length; index++) {
var input = inputs[index];
if (input.title == 'People Picker') {
input.setAttribute('excludeFromSpellCheck', true);
}
}
}</script>
In OOB we have one property (excludeFromSpellCheck) to avoid spell check for specific controls. But by default it will not work for people picker control because it is collection of input controls. If you inspect the control using IE developer toolbar you can find the login details hold by textarea field. So using following script I am setting above property to avoid spell check.
<script type="text/javascript">
_spBodyOnLoadFunctionNames.push("disableSpellCheckOnPeoplePickers");
function disableSpellCheckOnPeoplePickers() {
var inputs = document.getElementsByTagName('TextArea');
for (var index = 0; index < inputs.length; index++) {
var input = inputs[index];
if (input.title == 'People Picker') {
input.setAttribute('excludeFromSpellCheck', true);
}
}
}</script>
Where do you add the script, I have infopathform and i put a spell check, it works fine but it spell checks people pickers, where can i add this code.
ReplyDeleteAs per my knowledge, by default InfoPath will not have spell check feature. So I would like to understand how did you achieve this? For your information the above script works for only html forms.
ReplyDeleteYes you can put spell check on Infopath.
ReplyDeleteThis piece of code saved my day!!!
Thanks!
Thanks. Worked great for me.
ReplyDeleteIf you are using default list form then add it in edit-form
ReplyDeletegood information