Advertisement
M00371202

CMT 3315 coursework2 Registration

Apr 23rd, 2014
37
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.73 KB | None | 0 0
  1. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  2. <html xmlns="http://www.w3.org/1999/xhtml">
  3. <head>
  4. <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  5. <title>Friba Weather Forecast Station</title>
  6. <link href="style.css" rel="stylesheet" type="text/css" />
  7. <script type="text/javascript" src="jquery.min.js"></script>
  8. <script type="text/javascript" src="weather.js"></script>
  9. <script>
  10. function valemail(obj)
  11. {
  12. var field = obj.value
  13. var id = obj.id;
  14. if(field){
  15. var atpos = field.indexOf("@")
  16. var dotpos = field.lastIndexOf(".")
  17. var lastpos = field.length - 1
  18. if(atpos < 2 || dotpos - atpos < 2 || lastpos-dotpos > 4 || lastpos-dotpos < 2 ){
  19. return false
  20. }
  21. else{
  22. return true
  23. }
  24. }
  25. }
  26.  
  27. function submit_register(){// validation function for registration form
  28. var flag = 0;
  29. if(document.getElementById('fname').value==""){
  30. document.getElementById('fname').style.borderColor="#FF0000";
  31. flag = 1;
  32. }
  33. else{
  34. document.getElementById('fname').style.borderColor="";
  35. }
  36.  
  37. if(document.getElementById('lname').value==""){
  38. document.getElementById('lname').style.borderColor="#FF0000";
  39. flag = 1;
  40. }
  41. else{
  42. document.getElementById('lname').style.borderColor="";
  43. }
  44.  
  45. if(document.getElementById('email').value==""){
  46. document.getElementById('email').style.borderColor="#FF0000";
  47. flag = 1;
  48. }
  49. else{
  50. document.getElementById('email').style.borderColor="";
  51. var obj = document.getElementById('email');
  52. if(valemail(obj)==false){
  53. document.getElementById('email').style.borderColor="#FF0000";
  54. flag = 1;
  55. }
  56. else{
  57. document.getElementById('email').style.borderColor="";
  58. }
  59. }
  60.  
  61. if(document.getElementById('mobile').value==""){
  62. document.getElementById('mobile').style.borderColor="#FF0000";
  63. flag = 1;
  64. }
  65. else{
  66. document.getElementById('mobile').style.borderColor="";
  67. }
  68.  
  69. if(document.getElementById('password').value==""){
  70. document.getElementById('password').style.borderColor="#FF0000";
  71. flag = 1;
  72. }
  73. else{
  74. document.getElementById('password').style.borderColor="";
  75. }
  76.  
  77. if(document.getElementById('cpassword').value==""){
  78. document.getElementById('cpassword').style.borderColor="#FF0000";
  79. flag = 1;
  80. }
  81. else{
  82. document.getElementById('cpassword').style.borderColor="";
  83. }
  84.  
  85. if(document.getElementById('cpassword').value!=document.getElementById('password').value){
  86. document.getElementById('cpassword').style.borderColor="#FF0000";
  87. document.getElementById('password').style.borderColor="#FF0000";
  88. flag = 1;
  89. }
  90. else{
  91. document.getElementById('cpassword').style.borderColor="";
  92. document.getElementById('cpassword').style.borderColor="";
  93. }
  94.  
  95. if(flag==0){
  96. sessionStorage.login = document.getElementById('fname').value+" "+document.getElementById('lname').value;
  97. document.register_form.reset();
  98. $('#submit_status').html("Successfully register...");
  99.  
  100.  
  101. $('body').append('<div class="login_details">Welcome, '+sessionStorage.login+'</div>');
  102.  
  103. }
  104. else{
  105. $('#submit_status').html("Please check highlighted fields");
  106. }
  107.  
  108. }
  109. </script>
  110. </head>
  111.  
  112. <body>
  113.  
  114. <header>
  115. <div class="logo">Friba Shopping</div><!--title displays on the top left corner of the page-->
  116. <a href="basket.html">
  117. <div class="shop"><!-- shopping basket box -->
  118. <img src="images/cart.png" id="img0">
  119. <p>Item:<span id="item">0</span><br>Total:<span id="total">0</span></p>
  120. </div>
  121. </a>
  122. </header>
  123. <div class="pagelayout">
  124. <menu>
  125. <ul id="menu">
  126. <li><a href="index.html">Home</a></li>
  127. <li><a href="about.html">About us</a></li>
  128. <li><a href="register.html">Register</a></li>
  129. <li><a href="contact.html">Contact us</a></li>
  130. <li><a href="stock.html">Weather Forecast</a></li>
  131. <li><a href="login.html">Log In</a></li>
  132.  
  133. </ul>
  134. </menu>
  135.  
  136. <div class="page_content"><!-- the following codes is used to display the registration form on the content of the page-->
  137. <form action="index.html" method="get" id="register_form" name="register_form">
  138. <table width="600" border="0" cellspacing="0" cellpadding="5"><!-- creates tables including rows and columns-->
  139. <tr>
  140. <td colspan="2"><h2>Register</h2></td>
  141.  
  142. </tr>
  143. <tr>
  144. <td width="120">First name</td>
  145. <td><input type="text" name="fname" id="fname" /></td>
  146. </tr>
  147. <tr>
  148. <td>Last name</td>
  149. <td><input type="text" name="lname" id="lname" /></td>
  150. </tr>
  151.  
  152.  
  153. <tr>
  154. <td>Email</td>
  155. <td><input type="text" name="email" id="email" /></td>
  156. </tr>
  157.  
  158. <tr>
  159. <td>Mobile</td>
  160. <td><input type="text" name="mobile" id="mobile" /></td>
  161. </tr>
  162.  
  163. <tr>
  164. <td>Password</td>
  165. <td><input type="password" name="password" id="password" /></td>
  166. </tr>
  167.  
  168. <tr>
  169. <td>Confirm Password</td>
  170. <td><input type="password" name="cpassword" id="cpassword" /></td>
  171. </tr>
  172.  
  173. <tr>
  174. <td>&nbsp;</td><!-- line space-->
  175. <td><input type="button" name="button" id="button" value="Register" onclick="submit_register()" /> &nbsp; &nbsp; <span id="submit_status"></span></td> <!-- loads registration button-->
  176. </tr>
  177.  
  178. </table><!-- end table-->
  179. </form><!-- end or close form-->
  180.  
  181. </div>
  182.  
  183. </div>
  184. </body>
  185. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement