IT-Academy

JS Udalosti

Oct 4th, 2015
151
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.             comment = document.getElementsByName("comment")[0];
  2.             firstName = document.getElementsByName("firstName")[0];
  3.             firstNameWrong = document.getElementById("firstNameWrong");
  4.  
  5.             firstName.onblur = function () {
  6.                 if (firstName.value == "") {
  7.                     firstName.style.border = "1px solid red";
  8.                     firstNameWrong.style.display = "block";
  9.                 } else {
  10.                     firstName.style.border = "1px solid green";
  11.                     firstNameWrong.style.display = "none";
  12.                 }
  13.             };
  14.            
  15.             comment.onfocus = function () {
  16.                 if (comment.value == "Place for comment...") {
  17.                     comment.value = "";
  18.                 }
  19.             };
  20.  
  21.             comment.onblur = function () {
  22.                 if (comment.value == "") {
  23.                     comment.value = "Place for comment...";
  24.                 }
  25.             };
Advertisement
Add Comment
Please, Sign In to add comment