You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 

56 lines
2.1 KiB

  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="UTF-8">
  5. <meta http-equiv="X-UA-Compatible" content="IE=edge">
  6. <meta name="viewport" content="width=device-width, initial-scale=1.0">
  7. <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.0.2/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-EVSTQN3/azprG1Anm3QDgpJLIm9Nao0Yz1ztcQTwFspd3yD65VohhpuuCOmLASjC" crossorigin="anonymous">
  8. <title>Main page</title>
  9. </head>
  10. <body>
  11. <div class="container">
  12. <div style="margin-top: 3rem;">
  13. <h1>New article</h1>
  14. <form action="/articles" method="POST">
  15. <div class="form-group mt-2">
  16. <label for="title">Title</label>
  17. <input required type="text" name="title" id="title" class="form-control">
  18. </div>
  19. <div class="form-group mt-2">
  20. <label for="username">Username</label>
  21. <input required type="text" name="username" id="username" class="form-control" onkeyup="validateUsername()">
  22. </div>
  23. <div class="form-group mt-2">
  24. <label for="arttext">Article Text</label>
  25. <input required type="text" name="arttext" id="arttext" class="form-control">
  26. </div>
  27. <div class="mt-4">
  28. <a href="/" class="btn btn-secondary">Cancel</a>
  29. <button id="save" class="btn btn-primary">Save</button>
  30. </div>
  31. </form>
  32. </div>
  33. </div>
  34. <script>
  35. function validateUsername(){
  36. let username = document.getElementById("username").value
  37. var usernameRegex = /^[a-zA-Z]+$/
  38. if(usernameRegex.test(username) && username.length != 0 )
  39. {
  40. document.getElementById("save").classList.remove("disabled")
  41. }
  42. else
  43. {
  44. document.getElementById("save").classList.add("disabled")
  45. }
  46. }
  47. console.log('asdad')
  48. validateUsername()
  49. </script>
  50. </body>
  51. </html>