How to disable input recommendations? - html

I'm trying to prevent recommendations from coming up on an input box I created.
<input type="text" class="form-control" name="message" id="msg"
placeholder="Type a message" autocomplete="false">
But even with autocomplete="false" I still get the following:
I don't want the recommendations to show up on the input box.

I believe you should try using "off" instead of "false".
autocomplete="off"
In context to your given scenario, try the following code snippet
<input type="text" class="form-control" name="message" id="msg"
placeholder="Type a message" autocomplete="off">
If your inputs are wrapped up in a <form> you can use this attribute on the form instead of each individual <input>.
It tells the browser not to save data inputted by the user for later autocompletion on similar forms, though heuristics for complying vary by browser.
Here is the reference.

Related

Preventing Browser Text Input Suggestions 2021 chrome version 88.0.4324.190

How To Preventing Browser Text Input Suggestions from browser cookie, autocomplete="off" and others are not work.. Chrome Version : 2021 chrome version 88.0.4324.190
readonly is work for autofill its work proper, but autosuggestion is not.
<input type="email" class="form-control" id="email" name="email" placeholder="Enter Email" readonly onfocus="this.removeAttribute('readonly');" style="background-color: white;" autocomplete="off">
<input type="password" class="form-control" id="Password" name="password" minlength="6" placeholder="Enter Password">
what you want is here
change type="password" to type="text" and used in your input
-webkit-text-security: disc !important;
<input type="text" class="form-control" id="Password" name="password" minlength="6" placeholder="Enter Password" style="-webkit-text-security: disc !important;">
The only thing that still works in Chrome is creating random name not related to the field. Like autocomplete="new-password" to password field name.
Seems to be wrong, but it's a workaround.
So for your field named email, try to put autocomplete="new-email".
Even as stated as working in the SO below, autocomplete="off" still buggy:
Disabling Chrome Autofill
Also note that autocomplete="no" will appear to work but autocomplete="off" will not for historical reasons. autocomplete="no" is you telling the browser that this field should be auto completed as a field called "no". If you generate unique random autocomplete names you disable auto complete.
You need to keep in mind that's a feature from the Password Manager.
This is correctly stated here by Mozilla:
Preventing autofilling with autocomplete="new-password"
And why it's not always possible to prevent:
Browser compatibility
Note: In most modern browsers, setting autocomplete to "off" will not prevent a password manager from asking the user if they would like to save username and password information, or from automatically filling in those values in a site's login form. See the autocomplete attribute and login fields.
Solution #1:
As you can see, the autosuggestion show From this website.
As workaround, you need to change the fieldname from name="email" to something else, like name="user-email".
And handle the change inside your server logic.
Again in your server logic, generate a random name every time page is shown, like a UUID autocomplete="c821c4f0-7be8-11eb-9439-0242ac130002"
Solution #2:
Replace the input kind type="email" to type="text".
html:
<input type="text" class="form-control" id="user-email" name="user-email" placeholder="Enter Email" readonly onfocus="this.removeAttribute('readonly');" autocomplete="off" />
javascript:
window.onload = function () {
init();
}
function init() {
let x = document.getElementById("user-email");
if (x) x.setAttribute("type", "email");
}
Solution #3:
Add hidden fields before the real one:
HTML - Disable Password Manager
PS: Don't forget to place autocomplete="off" on the form which field belongs

How to restrict text box length in HTML using Angular JS

I want to restrict my Comments text box within 40 characters. I have used max=40.Its not working. Anyone please help me to fix this issue
Code:
<label for="cmds">Comments</label>
<input type="text" max="40" class="form-control" id="cmds" name="cmds"
data-ng-model="Audit.cmds" placeholder="null" >
Since you are dealing with comments, its better to use textarea instead of input type="text".
By using textarea you can do:
<textarea maxlength="40" id="comments" cols="" rows="">
Demo: https://jsfiddle.net/akshaymhatre89/L8fky10q/4/
<label for="cmds">Comments</label>
<input type="text" ̶m̶a̶x̶=̶"̶4̶0̶"̶ class="form-control" id="cmds" name="cmds"
data-ng-model="Audit.cmds" placeholder="null"
ng-maxlength="40" />
For more information, see AngularJS ng-maxlength Directive API Reference.

Prevent browser predicting input in input box

I am trying to prevent the browser giving me recommendations when I type into an input box. For example, if I type 'a' it will give me a list of items beginning with'a' that I have typed into an input box in my browser in the past.
I have tried autocomplete="false" but this doesnt work as far as I can tell. Autocomplete must be different to what I am looking for.
Perhaps it is a browser setting that cannot be controlled by the developer. Does anyone know if there is a way to do this?
It is working for me on this codepen link. It doesn't display prediction for email field, but it does show prediction for first name and last name field.
If it doesn't work for you then it must be your system software causing this. I'm using Chrome on Linux.
<form action="/action_page.php" autocomplete="on">
First name:<input type="text" name="fname"><br>
Last name: <input type="text" name="lname"><br>
E-mail: <input type="email" name="email" autocomplete="off"><br>
<input type="submit">
</form>
http://codepen.io/piyushpatel2005/pen/aJQaNN

HTML: Autofill form in bootstrap modal

In most HTML forms when I start typing something (say birth date) navigators propose to sit with previous similar entries. For instance on html form submit the second visit offers me the first visit entries.
However, when using a bootstrap modal containing a form, the same does not happen, for instance: with a form inside.
I do not want to use jquery autocomplete since I do not have a list of potential answers, I just want to have the same behavior in and outside modals.
Thanks.
Browser autofills are notoriously unpredictable - they make educated guesses about the data based on the name attribute of inputs. It's unlikely you'll be able to get this behavior consistently cross-browser.
can you try this :
add the attribute autocomplete = "on" on your form,
maybe it will do the job.
<form action="demo_form.asp" autocomplete="on">
First name:<input type="text" name="fname"><br>
Last name: <input type="text" name="lname"><br>
E-mail: <input type="email" name="email" autocomplete="off"><br>
<input type="submit">
</form>
source: http://www.w3schools.com/tags/att_input_autocomplete.asp
Read through this article it should help get things working for you.
Example:
<input type="text" id="name" name="name" autocomplete="name">
<input type="tel" id="tel" name="tel" autocomplete="home tel">

How to create an HTML form with pre-filled in "instructions" that clear when a user clicks in the box?

I have an HTML form as follow:
<form method="POST" action="http://">
Username: <input type="text" name="username" size="15" />
Password: <input type="password" name="password" size="15" />
<input type="submit" value="Login" />
</div>
</form>
I would like functionality such that the text fields have instructions in them that clear when a user clicks in the box so that I can save space and remove the words Username and Password from outside the forms.
How can this be achieved?
The feature you're looking for is called a "placeholder". (if nothing else, just knowing this term will help you search for more info in Google)
In modern browsers which support HTML5, this is a built-in feature which you can use very easily, as follows:
<input type='text' name='username' size='15' placeholder='User name' />
However, this method only works with up-to-date browsers which support this feature.
Older browsers will need to have some Javascript code to do it. Fortunately, there are a number of scripts you can use, including some written as JQuery plug-ins. The ones I'd recommend are those which tie into the placeholder attribute on the input field, so that you can support it natively in the browsers which have this feature and fall-back to Javascript for those that don't.
Try this one: http://www.hagenburger.net/BLOG/HTML5-Input-Placeholder-Fix-With-jQuery.html
If you use HTML5 you can do this using the placeholder attribute:
<form method="POST" action="http://">
<label for="username">Username:</label>
<input placeholder="Username" id="username" name="username" size="15">
<label for="password">Password:</label>
<input placeholder="Password" type="password" id="password" name="password" size="15">
<input type="submit" value="Login">
</form>
I'd still include the Username and Password text wrapped in <label> tags for accessibility, but you could always hide them with some CSS like this:
form {
position:relative;
}
label {
position:absolute;
top:-9999px;
}
These are commonly called watermarks and require javascript.
Look at the jQuery-watermark plugin.
I wrote a custom one because I wanted to have a specific behaviour.
https://90dayjobmatch.com/js/jquery.wf.formvaluelabel.js
Usage:
$('#signup_job_title').formvaluelabel({text:'eg. Graphic Artist'});
Let me know if you have any questions about it.
HTH
As others have noted, there is an attribute in HTML5 that allows this called placeholder - read about it here:
http://diveintohtml5.info/forms.html
http://dev.w3.org/html5/spec/Overview.html#the-placeholder-attribute
This does not require Javascript, but it is not supported by older browsers (see http://caniuse.com/#feat=input-placeholder).
It should be noted that placeholder is not meant to replace <label>s, which you are not using and probably should be.
<label for="username">Username:<label>
<input type="text" id="username" name="username" placeholder="Enter your username" size="15" />
Labels are important for a variety of reasons and it is bad practice to not use them.