Hello devs I'm quite new to react and js i'm stuck with this issue any help would be appreciated much, i have a basic form coded in react which takes input from user, when the user click sign in and the credentials are authenticated and validated then the browser should ask user if the user wants to save the password in browser memory.
HTML:
<form onSubmit={this.SignmeIn} autoComplete="on" >
<div className="form-group">
<label htmlFor="email">email</label>
<input type="email" className="form-control" name="email" id="email" placeholder="Email" required="" ref="email" />
</div>
<div className="form-group">
<label htmlFor="password">password</label>
<input type="password" className="form-control" name="password" id="password" placeholder="Password" required="" ref="password" />
<span id="ErrorMessage"></span>
</div>
<div className="form-group">
<button type="submit" className="btn btn-default btn-lg">sign in</button>
</div>
</form>
and here is the SignmeIn function called on submission of form
SignmeIn: function (e) {
e.preventDefault();
var formData = {
"email": this.refs.email.value,
"password": this.refs.password.value
}
$
.ajax({
username:$('input[name=email]').val(),
password:$('input[name=password').val(),
type: 'POST',
url: url + '/signin',
data: formData
})
.done(function (data) {
console.log(data);
if ( typeof data.UserName ==='undefined'||!data.UserName) {
alert('Wrong username or password');
}
else{
alert('welcome ' + data.UserName + "! You are signed in ");
}
})
.fail(function (data) {
console.log('data');
})
i want the browser to display a dialogue asking for user consent whether or not the user want to save the password in browser cache.