G
G
Good Samaritan2018-02-06 13:52:22
JavaScript
Good Samaritan, 2018-02-06 13:52:22

Is it possible to transliterate the entered string in the form?

I have a form

<form action="/ru/search/node/" method="get" id="searchform">
                        <span class="icon"><i class="fa fa-search"></i></span>
                        <input type="search" id="search" placeholder="Поиск..." />
                        <input type="submit">
                    </form>

Using js code, I substitute the value from the form input into the address bar
document.getElementById('search').addEventListener('input',function(){
            var form=document.getElementById('searchform');
            form.action=form.action.replace(/(\/search\/node\/).+/,'$1')+this.value;
            console.log(form.action);
        });

How can I transliterate Russian characters into Latin before this substitution?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
Dmitry Kim, 2018-02-06
@djamali

function translit(value){
    return 'translit = ' + value; // здесь происходит транслит
}

document.getElementById('search').addEventListener('input',function(){
            var form=document.getElementById('searchform');
            form.action=form.action.replace(/(\/search\/node\/).+/,'$1')+ translit(this.value);
            console.log(form.action);
        });

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question