Change textbox text in JavaScript

前端 未结 4 1785
离开以前
离开以前 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:18

    Given a function in javascript:

    function clearOther(which){
     document.getElementById(which).value='';
    }
    

    this can then be called when you focus on one textbox, passing the id of the other:

    
    
    

    working example --> http://jsfiddle.net/CwWKn/

提交回复
热议问题