Advertisement
Guest User

Untitled

a guest
Feb 27th, 2017
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.             var voltageValid = document.forms["form"]["voltage"].value;
  2.             var currentValid = document.forms["form"]["current"].value;
  3.             var resistanceValid = document.forms["form"]["resistance"].value;
  4.             var fieldsNull = 0;
  5.  
  6.             if (voltageValid == null || voltageValid == "") {
  7.                 fieldsNull++;
  8.                 return false;
  9.             }
  10.  
  11.             if (currentValid == null || currentValid == "") {
  12.                 fieldsNull++;
  13.                 return false;
  14.             }
  15.  
  16.             if (resistanceValid == null || resistanceValid == "") {
  17.                 fieldsNull++;
  18.                 return false;
  19.             }
  20.  
  21.             var p = document.createElement('p');
  22.  
  23.             if (fieldsNull == 3) {
  24.                 var errorText = document.createTextNode("Please Only Fill 2 Fields");
  25.                 p.appendChild(errorText);
  26.             }
  27.             else {
  28.                 var allText = document.createTextNode(voltageValid + ' ' + currentValid + ' ' + resistanceValid);
  29.                 p.appendChild(allText);
  30.             }
  31.  
  32.             document.body.appendChild(p);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement