In my country, we can use a postal code to obtain data regarding the location, such as the address, neighborhood, city and state.
For this, I use the web component. When the user enters the zip code (postal code), a web request is made and the data is retrieved in the text box.
If it is not found (error 401) I inform the user that they must go to the Correios website and obtain the necessary data.
As you can see, I’m using the lost focus textbox. As soon as it loses focus, the data is included.I’d like the response to appear after typing a short time, about 2 to 5 seconds. I was thinking about On text changed with clock.
Can anyone tell me how to do this?
in the when text box text got changed, if the length of the text is = 8 then hide the keypaa then take get request and do not try to call every few sec the GET request.
that is not fair for the project. if the zip code is 8 digit in length then what type of request the OP want to achieve? after getting the 8 digit only get request should take complete
So you would like to execute the GET only after the user has entered 8 digits, this would mean that every time the textbox contains 8, a GET is executed.
If the user has 7 digits and keeps adding and removing the eighth digit, GETs would be executed without delay.
By using a timer, even if the user performs a “bruteforce”, a delay is still applied which slows down the requests.