gpt4 book ai didi

javascript - 检查网页上的文本框以获取特定字符串

转载 作者:行者123 更新时间:2023-11-30 14:25:20 25 4
gpt4 key购买 nike

我需要一个空的文本框,如果有人输入特定文本并点击提交按钮,它会将他们重定向到另一个站点,如果文本是其他内容,则会重定向到另一个网站。

最佳答案

你想要做的是使用这段代码:

HTML

<input type="text" id="inputText" />
<button type="submit" onclick="buttonClicked()"></button>

JavaScript:

function buttonClicked() {
if (document.getElementById("inputText".value == "YourText")) {
window.location.href = "yourfile.html";
}
else {
window.location.href = "otherfile.html";
}
}

关于javascript - 检查网页上的文本框以获取特定字符串,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52031246/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com