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