我想使用 HTML5 拼写检查属性来检查输入的拼写错误。如果用户尝试提交拼写错误,使用 angularJS 将显示警报。有什么方法可以访问某些状态,该状态表示是否在文本块中发现了拼写错误。
最佳答案
您可以使用这个 javaScript 插件:
https://www.javascriptspellcheck.com/
要使用它,您只需解压缩并引用它。它还在其站点上提供了“Hello World”教程和记录良好的方法。
提供的工作示例代码如下:
<script type='text/javascript' src='/JavaScriptSpellCheck/include.js' ></script>
<script type='text/javascript'>$Spelling.SpellCheckAsYouType('myTextArea')</script>
<textarea name="myTextArea" id="myTextArea" cols="30" rows="4" style = 'max-width:500px;width:100%;height:200px;margin-bottom:20px'>
This this is a simple exampl of Spell-checking As-You-Type using javascript spellcheck.
It works in almost any browser, and supports upto 24 international languages.
The button bellow shows an alternative way to spellcheck using javascript spellcheck - using a dialog iwndow!
</textarea>
<input type="button" value="Spell Check in a Dialog" onclick="$Spelling.SpellCheckInWindow('myTextArea')" />
关于HTML5 拼写检查 - 确定是否发现任何拼写错误的单词的任何方法,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22725748/