index.html 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  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. <title>A-Level</title>
  8. </head>
  9. <body>
  10. <script>
  11. // <!-- Password,LoginForm -->
  12. function Password(parent, open){
  13. const pass = document.createElement('input')
  14. const btn = document.createElement('button')
  15. const lgn = document.createElement('input')
  16. const sbmt = document.createElement('button')
  17. sbmt.innerText = 'Submit'
  18. lgn.placeholder = "login"
  19. pass.placeholder = "password"
  20. btn.innerText = 'Show'
  21. parent.prepend(sbmt)
  22. parent.prepend(btn)
  23. parent.prepend(pass)
  24. parent.prepend(lgn)
  25. btn.addEventListener('click', () => this.setOpen(!this.open))
  26. btn.addEventListener('click', () => {
  27. btn.innerText = (btn.innerText === 'Show') ? btn.innerText = 'Hide' : btn.innerText = 'Show';
  28. })
  29. sbmt.setAttribute('disabled', true)
  30. oninput = () =>{
  31. if(pass.value.length < 1 || lgn.value.length < 1 ){
  32. sbmt.setAttribute('disabled', true)
  33. }
  34. else{
  35. sbmt.removeAttribute('disabled')
  36. }
  37. }
  38. this.open = open
  39. this .setOpen = (value) => {
  40. this.open = value
  41. render()
  42. }
  43. this.getOpen = () => {
  44. return this.open
  45. }
  46. const render = () => {
  47. pass.setAttribute('type', `${this.open ? 'text' : 'password'}`);
  48. lgn.setAttribute('type', `${this.open ? 'text' : 'password'}` );
  49. }
  50. return render()
  51. }
  52. let p = new Password(document.body, false)
  53. // Password Verify
  54. // function Password(parent,open){
  55. // const pass1 = document.createElement('input')
  56. // const pass2 = document.createElement('input')
  57. // const btn = document.createElement('button')
  58. // pass1.placeholder = 'password 1'
  59. // pass2.placeholder = 'password 2'
  60. // pass2.id = 'pass2'
  61. // btn.innerText = 'Submit'
  62. // btn.id = "btn"
  63. // document.body.prepend(btn)
  64. // document.body.prepend(pass2)
  65. // document.body.prepend(pass1)
  66. // btn.addEventListener('click', () => this.setOpen(!this.open))
  67. // this.open = open
  68. // this .setOpen = (value) => {
  69. // this.open = value
  70. // render()
  71. // }
  72. // this.getOpen = () => {
  73. // return this.open
  74. // }
  75. // document.getElementById('btn')
  76. // .onclick = () => {
  77. // document.getElementById('pass2').style.display = 'none';
  78. // }
  79. // oninput = () =>{
  80. // if(pass1.value !== pass2.value){
  81. // btn.setAttribute('disabled', true)
  82. // }
  83. // else{
  84. // btn.removeAttribute('disabled')
  85. // }
  86. // }
  87. // const render = () => {
  88. // pass1.setAttribute('type', `${this.open ? 'text' : 'password'}`);
  89. // pass2.setAttribute('type', `${this.open ? 'text' : 'password'}` );
  90. // }
  91. // return render()
  92. // }
  93. // let p = new Password(document.body, false)
  94. </script>
  95. </body>
  96. </html>