Browser offering to save passwords on HTML FORMS? - forms

I have a sign up page on my website. Now when a user signs up, the broswer will offer to remember the password and email on the sign up form. Which is not what I want at all, as I only want it where they will login.
Is there anyway to disable this, or is it out of my control.
<input type="post" autocomplete="off" />
autocomplete does not work.
Thanks,

You're setting the attribute on the <input> element - this should be an attribute of the <form> element.

A number of solutions can be found here:
Disable browser 'Save Password' functionality
Your best bet is probably using JavaScript to bypass the default form submission mechanism.

There isn't a completely bulletproof way to turn autocomplete off.
autocomplete is a non-standard tag. So YMMV depending on the browser.
Try setting the attribute on the form tag instead of the input tag. I've had it work when specified on the form tag in the past.

Related

If a form is missing the submit button, will the form still work to bots?

As a security measure, if I replace the <button type="submit"> with a <a class="button"> will the form still work for bots?
Normally yes, unless you check server side for that button being submitted along with the form.
If the form still has an action attribute attached to it, then it can still be submitted.
Try this for example:
document.getElementById("yourform").submit()

Hyperlinks in FOSUserBundle form label

So I've searched, googled, asked and even consulted the stars, but I haven't been able to find a solution to this specific problem.
When overriding an FOSUserBundle form,(specifically the Change Password form, but generally any other FOSUserBundle form), is there a way to set part of the field label to be a hyperlink?
Does the question make sense? I could elaborate if it doesn't.
The goal
I would like to have resultant HTML to look like this:
<div>
<label for="fos_user_resetting_form_has_acceptedtos">I agree to the <a href='/tos/'>Terms Of Service</a>.</label>
<input id="fos_user_resetting_form_has_acceptedtos" type="checkbox" value="1" name="fos_user_resetting_form[has_acceptedtos]">
</div>
What I've tried. . .
I have added the has_acceptedtos field to the User.php Entity and hooked into the controller, as per the instructions. And I have customized the field labels successfully.
Unfortunately, the following syntax, unsurprisingly, doesn't work either:
# app/Resources/FOSUserBundle/translations/FOSUserBundle.en.yml
# ...
# Password change
change_password:
submit: Change password
has_acceptedtos: I agree to the <a href='/tos'>Terms Of Service</a>.
...
I have even attempted to override the template, in an attempt to artificially create a label that would appear in the vicinity of the checkbox via css. Didn't work out too well.
Other than re-writing the entire FOSUserBundle to generate my own forms, can this even be accomplished?
Thanks in advance for any suggestions!
You'll have to use a combination of custom form theming and the Twig "raw" method to accomplish this.
Here's an answer that deals with a quite similar issue.

HTML5 Validation - PHP Form Action Attribute Empty

I was just validating some of my html5 pages on W3C with forms (PHP) on them and I get the following validation error:
Error: Bad value for attribute action on element form: Must be non-empty.
I thought that when the form submits to itself, it is good practice to leave the action attribute empty. Is this not the case? How can I fix this?
Thank you!
Simply put in "#".
<form action="#" method=post>
While browsers currently support the empty action since the spec says it's needed browsers in the future may not support it. In my opinion this is unlikely but you never know.
The reason I would add the action attribute is so if there is JavaScript somewhere that is actually posting the form the next developer in line is certain that this is were the form posts to and doesn't have to look though the relevant JavaScript files to see if this is intended or left out on mistake.
It can be fixed my putting the current page in the action attribute.
Hope that helps.

Form Automatically Submitting Upon Pressing 'Enter'

I have a very simple form with a single autocomplete widget. No submit button. I would like the form to act in such a way that it submits the form when the user selects a suggestion from the autocomplete, but does not submit otherwise. The problem is, the form automatically submits, filled in or not, whenever I press enter. However, if I add a hidden text input box, it resolves the issue, and I can only submit the form by selecting a suggestion from the autocomplete (submission via this mechanism is handled by some jQuery). Is there a more 'graceful' way of turning off the submit-on-return feature? Adding a hidden text input that I don't actually need definitely does not seem like the 'proper' way to do this and is probably a browser-dependent fix anyways (I'm using Chrome).
The "submit on enter" is a browser specific implementation. So I don't think there is anything we can do from JS to turn it off.
You might be able to force the issue by listening to "keypress" event in jQuery, but that seems heavy handed.
Another way you could possibly approach this (in theory, never done this) is using HTML5 Data attributes. i.e. on your form, have
<form data-ready="false">
</form>
Then set that attribute to "true" when you've selected your suggestion item.
In your Form submit handler, check for that attribute before deciding to allow form submission, or use .preventDefault() to stop it from submitting to server.

Is it possible to implement cross-browser username/password autocomplete in GXT?

Last night, I did a quick spike to try and implement username/password autocomplete in my GXT application. By "autocomplete", I don't mean Ajax-style autocomplete, but rather browser-based autocomplete. The best information I found on this via google is in the following post:
http://osdir.com/ml/GoogleWebToolkit/2009-04/msg01838.html
I didn't use this technique because I'm using GXT and didn't want to lose the look-and-feel of my login form.
I was successful in getting everything to work in Firefox (it populates both the username and password). In IE, it only populates the username, not the password. In Safari/Chrome, it doesn't work at all.
Here's how I did it:
Created a hidden HTML form on my HTML page that embeds GWT.
<form method="post" action="javascript:void(0)" style="display: none">
<input type="text" id="username" name="username" value=""/>
<input type="password" id="password" name="password" value=""/>
<input type="submit" value="Login" id="login"/>
</form>
When a user clicks on the "Login" button in my GWT application, populate the fields in this hidden form and "click" on the Login button (which will do nothing since the action="javascript:void(0)".
// Set the hidden fields to trigger the browser to remember
DOM.getElementById("username").setAttribute("value", username.getValue());
DOM.getElementById("password").setAttribute("value", password.getValue());
clickFormLogin();
...
public static native void clickFormLogin() /*-{
$doc.getElementById("login").click();
}-*/;
This works in Firefox 3.5 and prompts me to save the user/pass at the top of the screen. I believe I know why this doesn't work in Safari/Chrome and that's because the form's action doesn't go anywhere and the form is not submitted. If I change the action to be an actual URL and show the form, clicking on the form's Login button will save it in those browsers.
After typing this up as a question here, I got to thinking this might make a good blog post. Therefore, I copied everything and added a bit to my blog:
http://raibledesigns.com/rd/entry/browser_based_username_password_autocomplete
Summary and Question
While I'm glad I got it working in Firefox, I'm disappointed with IE's lack of password autocompletion. More than anything, I can't help but think there's a way to make this work in WebKit-based browsers.
Anyone know how to implement cross-browser username/password autocomplete in GWT (specifically GXT)?
Use persistent Cookies instead.
IE do save passwords, if user chooses to, but it works different. You need to type at least the username so it will autocomplete the password.
You need a plain vanilla html submit button. I think that will fix it.
http://groups.google.com/group/Google-Web-Toolkit/browse_thread/thread/2b2ce0b6aaa82461