admin管理员组文章数量:1134238
I am getting this message in the console I can't understand it. Please look into it
<!DOCTYPE html>
<html>
<head>
<title>registration page</title>
<script src="js/jquery.js"></script>
<script type="text/javascript">
$(document).ready(function(){
$('form').submit(function(event){
"use strict";
var valid = true,
message = '';
$('.error').remove();
$('form input').each(function() {
var $this = $(this);
if(!$this.val()) {
message='';
var inputName = $this.attr('name');
valid = false;
message += 'Please enter your ' + inputName + '\n';
$(this).closest('div').append('<div class="error">'+message+'</div>');
}
})
if(!valid){
event.preventDefault();
}else{
$('form').serialize()
}
})
})
</script>
</head>
<body>
<form>
<div>
<label>Name</label>
<input type="text" name="name"><br>
</div>
<div>
<label>File</label>
<input type="file" name="file"><br>
</div>
<div>
<label>password</label>
<input type="password" name="password"><br>
</div>
<button type='submit'>Submit</button>
</form>
</body>
</html>
The problem is despite no error I keep getting this message
[DOM] Input elements should have autocomplete attributes (suggested: "current-password"):
I have been provided with a google link in console which take me to (More info: goo.gl/9p2vKq)
I am getting this message in the console I can't understand it. Please look into it
<!DOCTYPE html>
<html>
<head>
<title>registration page</title>
<script src="js/jquery.js"></script>
<script type="text/javascript">
$(document).ready(function(){
$('form').submit(function(event){
"use strict";
var valid = true,
message = '';
$('.error').remove();
$('form input').each(function() {
var $this = $(this);
if(!$this.val()) {
message='';
var inputName = $this.attr('name');
valid = false;
message += 'Please enter your ' + inputName + '\n';
$(this).closest('div').append('<div class="error">'+message+'</div>');
}
})
if(!valid){
event.preventDefault();
}else{
$('form').serialize()
}
})
})
</script>
</head>
<body>
<form>
<div>
<label>Name</label>
<input type="text" name="name"><br>
</div>
<div>
<label>File</label>
<input type="file" name="file"><br>
</div>
<div>
<label>password</label>
<input type="password" name="password"><br>
</div>
<button type='submit'>Submit</button>
</form>
</body>
</html>
The problem is despite no error I keep getting this message
[DOM] Input elements should have autocomplete attributes (suggested: "current-password"):
I have been provided with a google link in console which take me to (More info: goo.gl/9p2vKq)
Share Improve this question asked Mar 3, 2019 at 15:22 vinayak shahdeovinayak shahdeo 1,4682 gold badges13 silver badges23 bronze badges 1- its better to set autocomplete to "off" it will help later – Profnird Commented Oct 16, 2021 at 20:13
8 Answers
Reset to default 167Try changing
<input type="password" name="password">
to
<input type="password" name="password" autocomplete="on">
Autocomplete lets web developers specify what (if any) permission the user agent has to provide automated assistance in filling out form field values, as well as guidance to the browser as to the type of information expected in the field.
It's pretty powerful.
Turning off Autocomplete
You have the below options for working with errors of the below format Input elements should have autocomplete attributes thrown by the console by modifying:
<input type="password" name="password">
- Set the
autocomplete
attribute tooff
at the<form>
or<input>
which:- Enforces browser to NOT store any data
- Disables caching form data in the session history
<input type="password" name="password" autocomplete="off">
- Another way to prevent autofilling by the browser is:
The below suggestions are browser specific
<input type="password" name="password" autocomplete="new-password"> <!-- For Mozilla-->
<!-- or -->
<input type="password" name="password" autocomplete="current-password"> <!-- For Chrome-->
From Chromium Projects' Design Documents:
Autocomplete attributes help password managers to infer the purpose of a field in a form, saving them from accidentally saving or autofilling the wrong data.
You can use the autocomplete
attribute on an HTML element that needs to be managed by a password manager for automatically filling its value. The value of autocomplete
attribute depends on the field about which you want to convey more information to the password manager. Consider the following examples:
- Current password field -
autocomplete="current-password"
- New password field -
autocomplete="new-password"
- Credit card field -
autocomplete="cc-number"
Its in chrome.. It is to ensure that browsers' and extensions' password management functionality can understand your site's sign-up, sign-in and change-password forms by enriching your HTML with a dash of metadata.
this might help you https://www.chromium.org/developers/design-documents/form-styles-that-chromium-understands
TypeScript 3.9 caused me to use autoComplete -- capital "C"
React with Bootstrap required me to use autoComplete with capital "C" as well.
I know that the question got answered, this is for those people who want to remove this warning message from console while using "react.js"
just add this in the input field
autoComplete="true"
here is the full one
<input type="password" className="form-control" placeholder="Password"
autoComplete="true"
name='password'
required={true} />
In React, input element can have autoComplete prop. This prop helps users to fill forms faster, especially on mobile devices. The name can be confusing, as it's more like an autofill. You can learn more about it from : https://html.spec.whatwg.org/multipage/form-control-infrastructure.html#autofill
本文标签: javascriptInput elements should have autocomplete attributesStack Overflow
版权声明:本文标题:javascript - Input elements should have autocomplete attributes - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1736848932a1955417.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论