JSFiddle - React, Tailwind, and code Playground

by s4ty

HTML

<link rel="stylesheet" href="http://s4ty-testarea.s4.ohost.de/jQuery-board/css/jquery-ui-1.8.20.custom.css">
<input id="plz" type="textbox "/>

JavaScript

$(function(){
    $('#plz')
        .keypress(function(e) {                   
                var key = e.charCode || e.keyCode || 0;                     
                var keychar = String.fromCharCode(key);
                if (  ((key == 8 || key == 9 || key == 46 || key == 35 || key == 36 || (key >= 37 && key <= 40)) && e.charCode==0)
                        || (key >= 48 && key <= 57) ) {
                    if($(this).val().length < 6) {
                        return;
                    } else {
                         e.preventDefault();
                    }
                    
                } else {
                    e.preventDefault();
                }
        })
        .change( function(){
            
            if($(this).val().length == 1) {
                
                $.ajax({
                    
                    url: 'getPLZ.php',
                    data: $(this).val(),
                    success: function (data){
                        $(this).autocomplete( "option", "source", data);                       
                    }
                    
                })
            }
            
        })
        .autocomplete();
});