Guest User

Untitled

a guest
Apr 4th, 2018
282
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.  var form1 = document.getElementById("form1");
  2.     form1.addEventListener("submit", function (event){
  3.         numberOfElements = form1.length;
  4.         // I should check if any of the values in the textboxes include #, !, ? or ' and if they do, then I should stop the execution
  5.         for (i = 0; i < numberOfElements; i++)
  6.         {
  7.             if ((form1[i].value.includes("#")) || (form1[i].value.includes("!")) || (form1[i].value.includes("?")) ||(form1[i].value.includes("'")))
  8.                 // TypeError: form1[i].value is undefined
  9.             {
  10.                         alert("You have entered either #, !, ? or '.");
  11.                         event.preventDefault();
  12.             }
  13.         }
Advertisement
Add Comment
Please, Sign In to add comment