Change textbox text in JavaScript

前端 未结 4 1788
离开以前
离开以前 2021-01-26 07:44

I\'m allowing a user to use either one of two textboxes to search a database - one is an ID field, and one is a freetext field. I\'m using ASP.NET with C# btw.

Anyway, a

4条回答
  •  迷失自我
    2021-01-26 08:12

    [Demo]

    var tbox1 = document.getElementById('tbox1');
    var tbox2 = document.getElementById('tbox2');
    
    tbox1.onfocus = function() {
      tbox2.value = "";
    };
    
    tbox2.onfocus = function() {
      tbox1.value = "";
    };
    

提交回复
热议问题