Last active
September 30, 2018 16:07
-
-
Save Mirch/a308febfcc4381d220b451a7a7c735d3 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@model RandomPassword.Models.UserRegisterModel | |
@{ | |
ViewData["Title"] = "Register"; | |
} | |
<h2>Register</h2> | |
<h4>UserRegisterModel</h4> | |
<hr /> | |
<div class="row"> | |
<div class="col-md-4"> | |
<form asp-action="Register"> | |
<div asp-validation-summary="ModelOnly" class="text-danger"></div> | |
<div class="form-group"> | |
<label asp-for="Username" class="control-label"></label> | |
<input asp-for="Username" class="form-control" /> | |
<span asp-validation-for="Username" class="text-danger"></span> | |
</div> | |
<div class="form-group"> | |
<label asp-for="Password" class="control-label"></label> | |
<input readonly="readonly" id="passwordInput" asp-for="Password" class="form-control" /> <!-- mark as readonly and add id --> | |
<button onclick="generatePassword()">Generate password</button> <!-- create button that triggers the generatePassword() function--> | |
<span asp-validation-for="Password" class="text-danger"></span> | |
</div> | |
<div class="form-group"> | |
<input type="submit" value="Create" class="btn btn-default" /> | |
</div> | |
</form> | |
</div> | |
</div> | |
<script> | |
function generatePassword() { | |
event.preventDefault(); | |
$.get( | |
"/Auth/GeneratePassword", | |
function (data) { | |
document.getElementById("passwordInput").value = data; | |
} | |
); | |
} | |
</script> | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment