Override browser spellchecking with your own?

I'm writing a form with javascript validation, I'd like to override the browser's built in spell checking.

For example, let's say I'm checking serial numbers and they all pass a regex text. I'd like to highlight the ones who don't in the browser much likes the browser highlights words with invalid spelling.

All I could come up with is disabling the browser's built in spell checking

So to sum it up

Is there a simple way to override a browser's built in spell check (sort of how like you override the comparator when you sort an array in javascript)

If there is not, is there a simple way to emulate such behavior?

Thanks a lot

Answers


The short answer; no, there is no Spellcheck API that JavaScript can hook into. Besides these kinda seem like different goals; a spellcheck is about natural language whereas you seem to really want input validation. You'd be better simply applying a different background / border colour or similar hint to the user via CSS when your JavaScript code detects an invalid serial (especially since each browser will render spellcheck errors differently anyway).


I haven't evaluated the code, but CkEditor manages to disable browser spell checking. It has a config setting that's set to true by default: disableNativeSpellChecker

config.disableNativeSpellChecker = true;

The setting is used within the "wysiwygarea" plugin, here's a link to the plugin code: wysiwygarea plugin

Maybe you can use it as a basis for your own code to disable browser spell checking.


Check out the demo from the Url below, it think it might be helpful in your case although it works just with HTML5.

http://jsfiddle.net/0GiS0/ZU74B/

Here is the code they used in the demo:

window.onload = function(){

    var support = document.getElementById("support");

    if('spellcheck' in document.createElement('textarea'))
    {
        support.textContent = "Your browser supports spellcheck";
        support.style.color = "green";
    }
}

Need Your Help

get user likes from FBSDK graph Api (V 2.5)

ios facebook swift facebook-graph-api

I am trying to retrieve all pages a user has liked on Facebook in my app. Taking from the Graph API, here is my code:

Check if jar running from shell

java shell sh executable-jar

I have a java jar program that I am trying to run on startup of my machine. Ideally, the shells script will check every 60 seconds to assure that the jar is running. How do I check if the jar is ru...