Last Updated: April 19, 2016
· gnclmorais

Trigger 'Remember password' notice in AJAX forms

You just made a beautiful, smooth, and AJAX-powered login form, but browsers don't suggest to store the credentials you just entered? No problem. I found something like the bellow example to work.


<form id="loginform" onSubmit="return login(this);">
    <input name="username" type="text" value="" required="required" />
    <input name="password" type="password" value="" required="required" />
    <input type="submit" name="doLogin" value="Login" />


function login (f) {
    var username = f.username.value,
        password = f.password.value;

    // AbracadabrAJAX here

    // This is crucial to stop the form from performing a POST request:
    return false;

This is not a protip per se, but it's something I just discovered today, so I'm storing it here. For more info, check the original source here.