如果值为空,则输入[type = text]中不考虑空白值

时间:2022-11-13 19:00:09

I am having simple HTML code:

我有简单的HTML代码:

<form action="login_validation.php">
    <input type="text" name="username1" placeholder="Username" value="">
    <input type="password" name="upassword" placeholder="Password" value="">
</form>

My output is:

我的输出是:

如果值为空,则输入[type = text]中不考虑空白值

But, I am confused, why this has happened (auto-filled username and password) even I have assigned the value="" (assigned blank value) in HTML.

但是,我很困惑,为什么会发生这种情况(自动填充的用户名和密码),即使我已经在HTML中分配了值=“”(指定的空白值)。

Why blank value is not consider in HTML?

为什么在HTML中不考虑空白值?

3 个解决方案

#1


Your field are yellow. This means that the auto-complete feature of your browser kicked in and filled your fields for you.

你的领域是黄色的。这意味着您的浏览器的自动完成功能会启动并填充您的字段。

Hence, your HTML is fine.

因此,您的HTML很好。

#2


This will help:

这将有助于:

<form action="login_validation.php" autocomplete="off">
    <input type="text" name="username1" placeholder="Username" value="">
    <input type="password" name="upassword" placeholder="Password" value="">
</form>

#3


You can disable this by adding the attribute autocomplete="off" to the input boxes, though this isn't acknowledged by all browsers

您可以通过在输入框中添加属性autocomplete =“off”来禁用此功能,但并非所有浏览器都会对此进行确认

EDIT: Zheka you pretty much just copied my answer.

编辑:哲卡你几乎只是复制了我的答案。

#1


Your field are yellow. This means that the auto-complete feature of your browser kicked in and filled your fields for you.

你的领域是黄色的。这意味着您的浏览器的自动完成功能会启动并填充您的字段。

Hence, your HTML is fine.

因此,您的HTML很好。

#2


This will help:

这将有助于:

<form action="login_validation.php" autocomplete="off">
    <input type="text" name="username1" placeholder="Username" value="">
    <input type="password" name="upassword" placeholder="Password" value="">
</form>

#3


You can disable this by adding the attribute autocomplete="off" to the input boxes, though this isn't acknowledged by all browsers

您可以通过在输入框中添加属性autocomplete =“off”来禁用此功能,但并非所有浏览器都会对此进行确认

EDIT: Zheka you pretty much just copied my answer.

编辑:哲卡你几乎只是复制了我的答案。