Warm tip: This article is reproduced from stackoverflow.com, please click
google-apps-script html javascript

Clear all values in fields when input field length is less than 7

发布于 2020-04-03 23:49:49

I've created a web app where you can search for the employee details using app script.

I have a single input textbox and some disabled fields to display some data.

Actual Web App

Here's the code

The input field length is 7 numbers only and what I want is, when I delete 1 number and the length becomes 6 the disabled field will be empty.

Is there a way to do it? Thanks!

Questioner
Pamela Ann Nicole
Viewed
128
2020-01-31 23:41

add input listener for #zip input try this :

document.getElementById("zip").addEventListener("input", function(){
   if((this.value).length < 7){
      document.getElementById('est').value = "";
      document.getElementById('Eadd').value = "";
      document.getElementById('role').value = "";
      document.getElementById('rd').value = "";
      document.getElementById('prod').value = "";
      document.getElementById('Aht').value = "";
      document.getElementById('Ave').value = "";
   }
});