HTML:为什么Android浏览器显示" GO"而不是"接下来"在键盘上?而不是、接下来、键盘、浏览器

2023-09-12 03:01:02 作者:巳為、亽妇

我有一个包含以下元素(按顺序)的HTML登录表单:

I have an HTML login form that contains following elements (in this order):

输入类型=文字(用户名输入) 输入类型=密码(密码) 输入类型=提交(登录按钮) input type=text (user name input) input type=password (password) input type=submit (Login button)

为什么Android浏览器显示去的软键盘,而不是下一步按钮按钮,当焦点在文本输入?这会导致用户失败登录非常容易,因为输入用户名之后,用户presses右下方按钮,键盘(通常是正确的行动)和形式将与空密码,这显然是不能被提交去上班。 [这种行为将使万一我的浏览器设置为记住密码感和密码管理器将能够填写密码。然而,这是不是这种情况在这里,你可以在下面测试自己。]

Why does the Android browser show "Go" button in soft keyboard instead of "Next" button when the focus is in the text input? This causes user to fail to login very easily because after entering the user name, the user presses the bottom right button in the keyboard (usually the correct action) and the form will be submitted with an empty password, which obviously is not going to work. [This behavior would make sense in case my browser was set to remember passwords and the password manager would be able to fill in the password. However, this is not the case here as you can test yourself below.]

我想有输入类型的文字有下一步按钮,输入类型的密码(最后输入之前提交)有转到按钮。

I'd like to have the input type text to have "Next" button and the input type password (the last input before the submit) to have the "Go" button.

有问题的形式,例如可以为 https://peda.net/:login (用户界面目前始终在芬兰语)。

An example of problematic form is at https://peda.net/:login (the user interface is currently always in Finnish).

你知道这个问题真正的解决?我知道,如果我实现本地应用程序,我会使用安卓imeOptions =actionNext(见How改变了Android功能键键盘" GO"按钮QUOT&;接下来" )。然而,在这种情况下,它是一个HTML表格和Android默认浏览器。

Do you know a real fix for this issue? I know that if I were implementing native application, I'd use android:imeOptions="actionNext" (see How to change the Android softkey keyboard "Go" button to "Next"). However, in this case it's an HTML form and Android default browser.

问题是可见与至少以下配置:

The problem is visible with at least following configurations:

在浏览器系统的应用程序在Android 2.3.4(的CyanogenMod 7)运行 在浏览器系统的应用程序在Android 4.2.2(的CyanogenMod 10.1)运行 在浏览器系统的应用程序在Android 4.3.1(CyanogenMod的10.2 M1)运行 在浏览器系统的应用程序(AOSP浏览器)在A​​ndroid 4.4.2(CyanogenMod的11.0 M3)运行

推荐答案

Android浏览器总是显示进入的输入字段,因为在网络上某种形式(尤其是搜索框)没有提交按钮,并且只能由$ P激活$ pssing进入(Go是相当于输入)。

The Android Browser always displays Go for input fields because some forms on the web (especially search boxes) have no submit button, and can only be activated by pressing Enter (Go is equivalent to Enter).

相反,一些Android版本会显示在键盘的右下角,方便表单字段之间导航的tab键。

Instead some versions of Android will show a tab key in the bottom right of the keyboard to facilitate navigating between form fields.

我不认为你可以prevent任何这类行为的。

I don't think you can prevent either of these behaviours.

有两种可能的解决方法:

Two possible workarounds:

使用JavaScript来忽略提交登录表单,直到两个输入都是非空白:

Use JavaScript to ignore submission of the login form until both inputs are non-blank:

<form name="loginForm" onsubmit="return document.loginForm.user.value != '' && document.loginForm.pass.value != ''">
    <input type="text" name="user">
    <input type="password" name="pass">
    <input type="submit" value="Login">
</form>

最干净的解决办法是设置两个输入需要使用新的HTML5 属性需要 - < STRONG>但是 Android的浏览器不支持此呢。然而,一个好的办法是补充了JavaScript的回退所需的属性,如CSSKarma 描述了

打印机打印时出现网站代码

The cleanest solution would be to set both inputs to be required using the new HTML5 required attribute - but the Android Browser doesn't support this yet. However a good approach would be to supplement the required attribute with a JavaScript fallback such as that described by CSSKarma.