Change textbox text in JavaScript

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

    I +1'ed Jamiec 's answer, but you still have to have some logic for those who don't have JS enabled. Maybe use the ID field as a priority if BOTH field's are populated.

    if ((!box1.IsNullOrEmpty) & (!box2.IsNullOrEmpty)) {
        // Evaluate box1 (since box1 is the ID field)
    } else {
        if ((!box1.IsNullOrEmpty)) {
            // Evaluate box1
        } else {
            // Evaluate box2
        }
    }
    

提交回复
热议问题