Advertisement
Guest User

Untitled

a guest
Feb 21st, 2019
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.42 KB | None | 0 0
  1. {% extends "layout.html" %}
  2.  
  3. {% block title %}
  4. Register
  5. {% endblock %}
  6.  
  7. {% block main %}
  8. <form action="/register" method="post" id="form" class="needs-validation">
  9. <div class="form-group">
  10. <input autocomplete="off" id="username" autofocus class="form-control is-invalid"
  11. name="username" placeholder="Username" type="text" required/>
  12. <div class="invalid-feedback">Invalid username</div>
  13. </div>
  14. <div class="form-group">
  15. <input class="form-control" id="password" name="password" placeholder="Password"
  16. type="password" aria-describedby="passwordHelpInline" required/>
  17. <small id="passwordHelpInline" class="form-text text-muted">
  18. Have to contain at least one letter, number and symbol: [@_!#$%^&*()<>?/\|}{~:]</small>
  19. </div>
  20. <div class="form-group">
  21. <input class="form-control" id="confirmation" name="confirmation"
  22. placeholder="Confirmation" type="password" required/>
  23. </div>
  24. <button class="btn btn-primary" type="submit">Register</button>
  25. </form>
  26. <script>
  27. $(document).ready(function() {
  28.  
  29. $("#form").submit(function() {
  30.  
  31. if (!$("#username").val()) {
  32. alert('You should provide a username')
  33. return false
  34. }
  35.  
  36. else if (!$("#password").val()) {
  37. alert('You should provide a password')
  38. return false
  39. }
  40.  
  41. else if (!$("#confirmation").val()) {
  42. alert('You should provide a confirmation')
  43. return false
  44. }
  45.  
  46. else if ($("#password").val() != $("#confirmation").val()) {
  47. alert("confirmation invalid")
  48. return false;
  49. }
  50.  
  51. $.getJSON("/check", {username: $("#username").val()}, function(data) {
  52. if (data.valid){
  53. alert(Valid username)
  54. }
  55. else {
  56. alert(Invalid username)
  57. }
  58. });
  59. return false;
  60.  
  61. });
  62. </script>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement