2
I have a < input type="text" id="A" >
, I would like that when typing any text in this input, it would be rewritten in input B, but before the text is rewritten, I would like it to be "cleaned". This cleaning is to take out the special characters of the text, and to replace the "spaces" by "-".
Currently I already do this "cleaning" with php, only it is not something dynamic. So not always the clean text is the way I want! An example of this is the following situation!
Before:
"Esse é um TEXTO que ééu quero LIMpar! Verá ele limpo em Seguida!"
Afterward
"esse-e-um-texto-que-eeu-quero-limpar--vera-ele-limpo-em-seguida-"
Now with this rewriting of the text I will be able to better control the final result! So in case I don’t like it I’ll be able to edit the final text even before registering in the database.
The php code I use to clear this text is:
$ltag = strtolower(preg_replace('{\W}', ' ', preg_replace('{ +}', ' ', strtr(utf8_decode(html_entity_decode($tag)), utf8_decode('ÀÁÃÂÉÊÍÓÕÔÚÜÇÑàáãâéêíóõôúüçñ'), 'AAAAEEIOOOUUCNaaaaeeiooouucn'))));