[英]Want to Add a submit button instead of Enter key
我想添加一个提交按钮而不是 Enter 键
这是我的代码
<!DOCTYPE html>
<html>
<body>
<input type="text" name="logsarchives" id="logsarchives" autocomplete="off" placeholder="Enter Console Command" onkeydown="redirect(this)">
</body>
<script>
function redirect(ele) {
if(event.key === 'Enter') {
if(ele.value === 'google')
window.location.href = 'https://google.com';
else
alert("Invalid");
}
}
</script>
</html>
从您的<input>
删除onkeydown="redirect(this)"
并添加提交按钮和包装表单:
<form method="post" action="https://where.you.want/to/process">
<input type="text" name="logsarchives" id="logsarchives" autocomplete="off" placeholder="Enter Console Command">
<input type="submit" name="submit" value="submit>
</form>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.