Guest User

Untitled

a guest
Feb 17th, 2018
114
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.50 KB | None | 0 0
  1. window.onload=function(){
  2.  
  3. const buttons = document.getElementsByTagName('button');
  4.  
  5. buttons[0].addEventListener ('click', function(){
  6. buttons[0].innerHTML = 'I am right'
  7. });
  8.  
  9. buttons[1].addEventListener ('click', function(){
  10. buttons[1].innerHTML = 'NO, I am right!'
  11. });
  12.  
  13. const box = document.getElementById('big-button');
  14. box.addEventListener('mouseover', function(){
  15. box.innerHTML = 'I SAID DO NOT HOVER';
  16. });
  17. box.addEventListener('mouseout', function(){
  18. box.innerHTML = 'DO NOT HOVER OVER ME';
  19. });
  20.  
  21. const letters = document.getElementById('three');
  22. const result = document.getElementsByClassName('keystroke');
  23.  
  24. letters.addEventListener ('keydown', function () {
  25. let h1 = document.createElement('h1');
  26. h1.innerHTML = letters;
  27. });
  28.  
  29. const user = document.getElementById('user-button');
  30. const name = document.getElementById('user-info');
  31. const pass = document.getElementById('password-button');
  32. const word = document.getElementById('password-info');
  33.  
  34. user.addEventListener('click', function(){
  35. const digits = /^[0-9a-zA-Z]+$/;
  36. if(name.value.match(digits))
  37. alert('Valid Name')
  38. else
  39. alert('Username must have one number')
  40. });
  41.  
  42. pass.addEventListener('click', function(){
  43. const num = /^[0-9]+$/;
  44. if (word.value.match(num))
  45. alert('Valid Password')
  46. else
  47. alert('Password Must be Numeric')
  48. });
  49. }
Add Comment
Please, Sign In to add comment