3

This is quite a common question but the solutions I found in other people posts are either related to a specific browser (mostly firefox) or incorrect usage of names (name="U12-678132-34")

My issues are with browsers other then Firefox (Firefox all ways works).

The form that I use is pretty standard HTML form but the submission of it is done with javascript (jQuery AJAX).

Firefox all ways asks to remember the password (if it is a new user) and refills the form if you land on that same page again. But when it comes to Chrome/Safari/IE8-9 then they never request to save a password if the form is submitted with javascript. (By the way I did check if the browsers dont have the - never remember passwords turned on)

My submit happens when you click on the link inside the form or if you just click the "ENTER" button on your keyboard, then it initiates the $.submit() method.

Is there a specific way that the submit needs to occur so that the browser would request to save a password like firefox does? or is there a way to at least tell a specific browser like Chrome/IE to force that type of request?

Form example:

<form class="loginform" method="post" action="">
    <div class="inputfield">
        <input name="email" type="text" class="emailaddress inputclass" value="" title="Email Address" />
    </div>      
    <div class="inputfield">
        <input name="password" type="password" class="password inputclass" title="Password" value="" />
    </div>              
    <div class="submit">
        <a href="javascript:void(0);" class="signinbutton"></a>
        <div class="checking">
            <img src="/preloaders/login-preloader.png"/>
        </div>
        <input type="submit" name="submit" value="submit" style="display:none"/>
    </div>
</form>
Alex
  • 1,630
  • 1
  • 20
  • 31
  • We have validations added for confirmation of inaccurate login attempt or to many login attempts and password reset. I know that making this form submit without javascript would resolve the issue but we would sacrifice the aesthetics, which is not an option for this project. – Alex Feb 03 '12 at 19:40

5 Answers5

3

This is browser behaviour and can't really be changed. Firefox might be "smart" enough to offer to save passwords without the form actually being submitted, but that risks having buttons in the form also trigger that option even if the button does something different. So in my opinion, it's a bad thing for Firefox to do (I've had many problems with Firefox submitting forms even though it shouldn't).

If you really want the save password option to show up, use an iframe and submit to the iframe, instead of using AJAX. You could then use AJAX from the iframe to keep the old behaviour.

Niet the Dark Absol
  • 320,036
  • 81
  • 464
  • 592
  • Hmm interesting.. I will try that so far the best suggestion :) – Alex Feb 03 '12 at 19:44
  • 1
    Seems that submitting to iframe no longer works in recent browsers. I haven't found other way yet. http://dev.vaadin.com/ticket/8405 – Oliv May 09 '12 at 07:25
0

One of the reason is that site should have a valid certificate. If it is not secured site, password save prompt will not appear after login.

gopi nath
  • 71
  • 3
0

attach click event to your submit button

$('#id_of_submit').click(function() {
   /your ajax logic
   return false;
});

and on link

$('#id_of_your_link').click(function() {
   $('#id_of_submit').click();
});

this will do the trick.

Senad Meškin
  • 13,597
  • 4
  • 37
  • 55
  • this will make the browser remember the username and password ? really ? – Manse Feb 03 '12 at 18:46
  • when submit button on form is pressed and firefox recognize form elements as password and username it will offer to save it. I have forms with the nice links and with hidden submit button. – Senad Meškin Feb 03 '12 at 18:49
  • my form work with both .click and .submit and on Firefox like I said in the question above works fine but it wont work on other browsers – Alex Feb 03 '12 at 19:42
0

Looking at the answer accepted on here - How can I get browser to prompt to save password? - it seems that a valid action might help.

But i would suggest its down to browser behaviour and cannot be controlled by HTML and/or JavaScript. If you want to remember the values entered use a Cookie

Community
  • 1
  • 1
Manse
  • 37,765
  • 10
  • 83
  • 108
0

As u r doing an AJAX post, then-

  1. Remove the <form> tags

  2. instead of <input type="submit", use button

  3. take the field values & AJAX post- on button click event

it might do the trick.

Avisek Chakraborty
  • 8,229
  • 10
  • 48
  • 76