Skip to content

Instantly share code, notes, and snippets.

@lengyijun
Created July 9, 2019 02:10
Show Gist options
  • Select an option

  • Save lengyijun/4d462ed614e85552217112c47fdb1fb2 to your computer and use it in GitHub Desktop.

Select an option

Save lengyijun/4d462ed614e85552217112c47fdb1fb2 to your computer and use it in GitHub Desktop.
<!DOCTYPE html>
<html>
<head>
<title>Login</title>
</head>
<body>
<div class="Login">
<h1>Validated Login Form</h1>
<form id="myform" onSubmit="handleSubmit()">
<label>Email</label>
<input type="text" name="email" data-test="email" value={{.email}} readOnly={true}/>
<label>Account</label>
<input type="text" data-test="account" name="account" id="account"/>
<input type="hidden" name="token" value={{.token}} id="c" />
<button type="submit" >
Login
</button>
</form>
</div>
<script>
function handleSubmit() {
var xhr = new XMLHttpRequest();
xhr.open("POST", "/login2", true);
xhr.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
var data="email="+{{.email}}+"&&token="+{{.token}}+"&&account="+document.getElementById("account").value;
console.log(data)
xhr.send(data);
}
</script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment