Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

spellchek property not working on preloaded data

Tags:

html

jquery

I want to do the spellcheck in all input field and textboxes in one of my html form. To do this I have used the following jquery code:

$(document).ready( function() {
    $("input[type='text'], textarea").prop('spellcheck',true);    
});

The spellcheck option is working fine while filling the form. But its not doing the checking on preloaded form data until the field is not clicked at least.

Please tell me a way to work it on preloaded data.

Thanks in advance.

like image 818
zakaria Avatar asked Jan 25 '26 09:01

zakaria


1 Answers

The issue comes from 2 things needing to be true (As far as my Chrome testing goes).

A) Whitespace is usually what triggers it.

B) The element has to be in focus to trigger the spellcheck

To handles this try something like this:

$(document).ready( function() {
  $("input[type='text'], textarea").each(function(){
    $(this).text( $(this).text() + " ");
    $(this).focus();
    $(this).blur();
  })
});

The only issue with this is you now have whitespace on the end of your inputs. To handle this I'd make sure that on submit you trim trailing whitespace.

Here is a simple jsfiddle: http://jsfiddle.net/seckela/MWLUn/

like image 159
Mikhail Amos Thomas Avatar answered Jan 27 '26 21:01

Mikhail Amos Thomas



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!