Запускать AJAX только в том случае, если введены два или более символов - PullRequest
1 голос
/ 11 ноября 2019

У меня есть следующий код:

<script>
    function pesquisa_cid_01() {
        var oHTTPRequest = createXMLHTTP(); 
        oHTTPRequest.open("post", "bd_ajax_ciat_cid.asp", true);
        oHTTPRequest.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
        oHTTPRequest.onreadystatechange=function() {
            if (oHTTPRequest.readyState == 4) {
                document.all.div_pesquisa_cid_01.innerHTML = oHTTPRequest.responseText;
            }
        }
        oHTTPRequest.send("busca_cid_01=" + encodeURIComponent(form_ciat_new.pesquisa_cid_01_form.value));
    }
</script>

Как заставить принудительно начать работу кода только с 2 и более символами, введенными при вводе формы?

Код формы:

<input type="text" name="pesquisa_cid_01_form" id="pesquisa_cid_01_form" class="form-control" onkeyup="pesquisa_cid_01();">
Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...