Hello devs我很反应和js我坚持这个问题任何帮助将不胜感激,我有一个基本形式编码反应,从用户输入,当用户点击登录和凭证经过身份验证和验证,然后浏览器应询问用户是否要将用户密码保存在浏览器内存中。
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>
这里是在提交表单
时调用的SignmeIn函数 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');
})
我希望浏览器显示一个对话框,要求用户同意用户是否要将密码保存在浏览器缓存中。