Replacing Wrong Words in a Text Field


I would like an idea of how to create something of the type, text field, where we enter some wrong word (s) and then it is corrected.

For example:

<body><input type="text" id="exibir" onkeyup="troca()"/></body>

<script language="javascript">
 function troca() {
 var str =   document.getElementById("exibir").value; 
 var res = str.replace(/case/gi, "casa");
 document.getElementById("exibir").value = res;

Before: case


Then: casa


Hypothesis - Here is a smart script behind the text field, correcting it or better replacing case with casa . Let's say that this script took something close to the typed word and displayed it in its correct form.

asked by anonymous 15.04.2016 / 03:41

1 answer


Good Person, this script was designed based on grotesque grammar mistakes commonly used in everyday life, both at the fingertips and at the tip of the tongue. Sometimes they do not even exist in dictionaries or have a completely different meaning from what you're trying to say. They are words we usually hear and are completely wrong. My Programming was successful, of what I had in mind, after extensive research. See:

<title>Correcao Ortografica/Gramatica</title>

padding: 10px 5px 10px 5px;  
border: 1px solid #f1f1f1f;
font-family: "lucida", tahoma, arial, verdana;
font-size: 12pt;
color: #111;

text-align: center;
width: 75%; 
font-size: 14pt;

border: 1px solid whitesmoke;
margin: 0 auto;
width: 61%;
text-align: left;
font-size: 12pt;


<h2>Alguns erros de português que você nem sabia que estava cometendo ...</h2>

<input type="text" onkeyup="corrigir(this.value)" id="txt" class="campo"/>

<hr width=70% color=whitesmoke size=1 darshed/>

<div class="outer">Digite alguma(s) Palavra abaixo no Campo acima:
<div class="inner">


<script language="javascript">
String.prototype.replaceAll = function(antes, depois){
var palavra = this;
var posicao = palavra.indexOf(antes);

while (posicao > -1){
palavra = palavra.replace(antes, depois);
posicao = palavra.indexOf(antes);

return (palavra);
function corrigir(txt){
ler = {
'superfluo': {'por': 'superfulo'},
'locaute': {'por': 'nocaute'},
'gaviota': {'por': 'gaivota'},
'guspir': {'por': 'cuspir'},
'holoforte': {'por': 'holofote'},
'imbigo': {'por': 'umbigo'},
'luvem': {'por': 'nuvem'},
'estrupo': {'por': 'estupro'},
'bulancia': {'por': 'ambulância'},
'bassoura': {'por': 'vassoura'},
'encostamento': {'por': 'acostamento'},
'escangalo': {'por': 'escandalo'},
'helecoptro': {'por': 'helicóptero'},
'ebisódio': {'por': 'episódio'},
'camioneiro': {'por': 'caminhoneiro'},
'iplisom': {'por': 'ipsilon'},
'trabesseiro': {'por': 'travesseiro'}, 
'trabisseiro': {'por': 'travesseiro'},
'dico': {'por': 'pico'},
'repescagem': {'por': 'refrescagem'}, 
'garfanhoto': {'por': 'gafanhoto'},
'dibre': {'por': 'drible'},
'tauba' : {'por': 'tábua'},
'falcudade': {'por': 'faculdade'},
'experiênca': {'por': 'experiência'},
'asteristico': {'por': 'asterisco'},
'subaco': {'por': 'suvaco'},
'gumerangue': {'por': 'bumerangue'},
'tevelisão': {'por': 'televisão'},
'cisnei': {'por': 'cisney'},
'prosta': {'por': 'prostata'},
'resitro': {'por': 'registro'},
'sigura': {'por': 'segura'},
'fervereiro': {'por': 'fevereiro'},
'congustivel' : {'por': 'combustivel'},
'onégaro': {'por': 'orégano'},
'mictorio': {'por': 'nictorio'},
'degote': {'por': 'decote'},
'resistro': {'por': 'registro'},
'bigalha': {'por': 'migalha'},
'guspe': {'por': 'cuspe'},
'delatavam': {'por': 'dilatavam'},
'rejuvenescimento': {'por': 'rejuvelhecimento'},
'vasculante': {'por': 'basculante'},  
'vasculhante': {'por': 'basculante'}, 
'poblema': {'por': 'problema'},
'pobrema': {'por': 'problema'},
'iorgute': {'por': 'iogurte'},
'mortandela': {'por': 'mortadela'},
'mendingo': {'por': 'mendigo'},
'mindingo': {'por': 'mendigo'},
'cardaço': {'por': 'cadarço'},
'salsicha': {'por': 'salchicha'},
'vinculando': {'por': 'veiculando'},
'reinterando': {'por': 'reiterando'},
'imperativo': {'por': 'hiperativo'}
var resultado = document.all.txt.value;
for (var i in ler)
resultado = resultado.replaceAll(i,ler[i].por);

I think the source code itself is self-explanatory, but if there is any doubt comment!


IMPORTANT! - I make it clear that this list was not built and / or modeled by me, this was done after research on the difference between spelling and grammar errors and the like. Here, being merely illustrative, não sou formado em letras . The real intention is to share what I have questioned. I expect good judgment from you.

16.04.2016 / 18:39