Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

like image 384
Benjamin Gruenbaum Avatar asked Jun 13 '12 13:06

Benjamin Gruenbaum


1 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).

like image 158
Graham Avatar answered Oct 13 '22 01:10

Graham