Advertisement
Guest User

Untitled

a guest
Sep 20th, 2017
114
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.72 KB | None | 0 0
  1. <html>
  2.  
  3. <head>
  4. <title>Question 8</title>
  5.  
  6. <script>
  7.  
  8. function ValidateForm(){
  9. var regexNum = /\d/;
  10. var regexLetter = /[a-zA-z]/;
  11. var email = document.ContactForm.Email;
  12. var phone = document.ContactForm.Telephone;
  13.  
  14.  
  15. if (email.value == "")
  16. {
  17. window.alert("Please enter a valid e-mail address.");
  18. email.focus();
  19. return false;
  20. }
  21. if (email.value.indexOf("@", 0) < 0)
  22. {
  23. window.alert("Please enter a valid e-mail address.");
  24. email.focus();
  25. return false;
  26. }
  27. if (email.value.indexOf(".", 0) < 0)
  28. {
  29. window.alert("Please enter a valid e-mail address.");
  30. email.focus();
  31. return false;
  32. }
  33.  
  34. if (phone.value == "")
  35. {
  36. window.alert("Please enter your telephone number.");
  37. phone.focus();
  38. return false;
  39. }
  40.  
  41. if (isNaN(phone.value)){
  42. window.alert("Please enter a valid telephone number.");
  43. return false;
  44. }
  45.  
  46. return true;
  47. }
  48.  
  49. function phonenumber()
  50. {
  51. var phone = document.ContactForm.Telephone;
  52. var phoneno = /^\d{10}$/;
  53. if(phone.value.match(phoneno))
  54. {
  55. return true;
  56. }
  57. else
  58. {
  59. alert("Contact no. must be of 10 digits");
  60. return false;
  61. }
  62. }
  63. </script>
  64. </head>
  65.  
  66. <body><font face="Helvetica">
  67. <h1><center>Question 8</h1><br /><br /></center>
  68. <form method="post" action="success.html";
  69. name="ContactForm" onsubmit="return ValidateForm() && phonenumber();">
  70. <p>Name: <input type="text" name="Name"></p>
  71. <p>Username: <input type="text" name="Username"></p>
  72. <p>Password: <input type="password" name="password1"></p>
  73. <p>Retype Password: <input type="password" name="password2"></p>
  74. <p>Gender:
  75. <input type="radio" value="male" name="gender">Male
  76. <input type="radio" value="female" name="gender">Female
  77. <input type="radio" value="other" name="gender">Other
  78. </p>
  79. <p>Programming Skills:
  80. <input type="checkbox" value="java" name="ps">Java
  81. <input type="checkbox" value="android" name="ps">Android
  82. <input type="checkbox" value="ruby" name="ps">Ruby
  83. <input type="checkbox" value="net" name="ps">.NET
  84. </p>
  85. <p>E-mail: <input type="text" name="Email"></p>
  86. <p>Contact No.: <input type="text" name="Telephone"><br>
  87. <p>College:
  88. <select type="text" value="" name="college">
  89. <option>SVIT</option>
  90. <option>New Eton</option>
  91. <option>St. Marys</option>
  92. <option>St. Esprit</option>
  93. <option>Eden</option>
  94. </select></p>
  95. <p><input type="submit" value="Submit" name="submit">
  96. </font>
  97. </form>
  98.  
  99. </body>
  100. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement