Advertisement
KodingKid

Javascript input - Extended with an email and phone number system

Apr 30th, 2021
106
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. var firstName = document.getElementById("name1").value;
  2. var age = document.getElementById("age").value;
  3. var secondName = document.getElementById("name2").value;
  4. var email = document.getElementById("email").value.indexOf("@");
  5. var phone = document.getElementById ("phone").value.indexOf("+");
  6. Submitted = "true";
  7. if (firstName.length > 15) {
  8.     alert("The name must have no more than 15 characters!")
  9.     Submitted = "false";
  10. }
  11. if (isNaN(age) || age < 10 || age > 120) {
  12.     alert("The age must be between numbers 10 and 120!")
  13.     Submitted = "false";
  14. }
  15. if (secondName.length > 15) {
  16.     alert("The name must have no more than 15 characters!")
  17.     Submitted = "false";
  18.  
  19. }
  20. if (email.length > 200) {
  21.     alert("The email must have no more than 200 characters!")
  22.     Submitted = "false";
  23. }
  24. if (phone.length > 20) {
  25.     alert("The phone number must have no more than 20 numbers!")
  26.     Submitted = "false";
  27. }
  28. if (Submitted == "false") {
  29.     return false;
  30. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement