Advertisement
Maria-I-Pap

Untitled

Nov 9th, 2016
163
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 9.05 KB | None | 0 0
  1. function sendAjaxGet() {
  2. var uname = document.getElementById('uname').value;
  3. var email = document.getElementById('email').value;
  4. var fname = document.getElementById('fname').value;
  5. var lname = document.getElementById('lname').value;
  6. var bdate = document.getElementById('bdate').value;
  7. var city = document.getElementById('city').value;
  8. var password = document.getElementById("password").value;
  9. var confirm_password = document.getElementById("confirm_password").value;
  10. var splChars = "*|,\":<>[]{}`\';()@&$#%";
  11.  
  12. var xhr = new XMLHttpRequest();
  13.  
  14. if(fname.length>20 || fname.length<3){
  15. alert("Name must be 3-20 characters");
  16. document.getElementById("fname").focus();
  17. event.preventDefault();
  18. }else{
  19. if (!(/^[a-zA-Z]+$/.test(fname))){
  20. alert("Name must contain only letters");
  21. document.getElementById("fname").focus();
  22. event.preventDefault();
  23. }
  24. }
  25.  
  26.  
  27. if(lname.length>20 || lname.length<4){
  28. alert("Last Name must be 4-20 characters");
  29. document.getElementById("lname").focus();
  30. event.preventDefault();
  31. }else{
  32. if (!(/^[a-zA-Z]+$/.test(lname))){
  33. alert("Last Name must contain only letters");
  34. document.getElementById("lname").focus();
  35. event.preventDefault();
  36. }
  37. }
  38.  
  39.  
  40. if(password.length<6 || password.length>10){
  41. alert("Password must be 3-20 characters");
  42. document.getElementById("password").focus();
  43. event.preventDefault();
  44. }else{
  45. for (var i = 0; i < password.length; i++) {
  46. if (splChars.indexOf(password.length.charAt(i)) === -1){
  47. alert("Password must contain at least one letters,one number and one symbol");
  48. document.getElementById("password").focus();
  49. event.preventDefault();
  50. }
  51. if(!(/^[a-zA-Z]+$/.test(lname))){
  52. alert("Password must contain at least one letters,one number and one symbol");
  53. document.getElementById("password").focus();
  54. event.preventDefault();
  55. }
  56. if(!(/^[0-9]+$/.test(lname))){
  57. alert("Password must contain at least one letters,one number and one symbol");
  58. document.getElementById("password").focus();
  59. event.preventDefault();
  60. }
  61. }
  62. }
  63.  
  64. if(password !== confirm_password) {
  65. alert("Passwords not match");
  66. event.preventDefault();
  67. } else {
  68. confirm_password.setCustomValidity('');
  69. }
  70.  
  71. event.preventDefault();
  72. }
  73.  
  74. function countryList(){
  75. var country_list = ["Afghanistan","Albania","Algeria","Andorra","Angola","Anguilla","Antigua &amp; Barbuda","Argentina","Armenia","Aruba","Australia","Austria","Azerbaijan","Bahamas","Bahrain","Bangladesh","Barbados","Belarus","Belgium","Belize","Benin","Bermuda","Bhutan","Bolivia","Bosnia &amp; Herzegovina","Botswana","Brazil","British Virgin Islands","Brunei","Bulgaria","Burkina Faso","Burundi","Cambodia","Cameroon","Cape Verde","Cayman Islands","Chad","Chile","China","Colombia","Congo","Cook Islands","Costa Rica","Cote D Ivoire","Croatia","Cruise Ship","Cuba","Cyprus","Czech Republic","Denmark","Djibouti","Dominica","Dominican Republic","Ecuador","Egypt","El Salvador","Equatorial Guinea","Estonia","Ethiopia","Falkland Islands","Faroe Islands","Fiji","Finland","France","French Polynesia","French West Indies","Gabon","Gambia","Georgia","Germany","Ghana","Gibraltar","Greece","Greenland","Grenada","Guam","Guatemala","Guernsey","Guinea","Guinea Bissau","Guyana","Haiti","Honduras","Hong Kong","Hungary","Iceland","India","Indonesia","Iran","Iraq","Ireland","Isle of Man","Israel","Italy","Jamaica","Japan","Jersey","Jordan","Kazakhstan","Kenya","Kuwait","Kyrgyz Republic","Laos","Latvia","Lebanon","Lesotho","Liberia","Libya","Liechtenstein","Lithuania","Luxembourg","Macau","Macedonia","Madagascar","Malawi","Malaysia","Maldives","Mali","Malta","Mauritania","Mauritius","Mexico","Moldova","Monaco","Mongolia","Montenegro","Montserrat","Morocco","Mozambique","Namibia","Nepal","Netherlands","Netherlands Antilles","New Caledonia","New Zealand","Nicaragua","Niger","Nigeria","Norway","Oman","Pakistan","Palestine","Panama","Papua New Guinea","Paraguay","Peru","Philippines","Poland","Portugal","Puerto Rico","Qatar","Reunion","Romania","Russia","Rwanda","Saint Pierre &amp; Miquelon","Samoa","San Marino","Satellite","Saudi Arabia","Senegal","Serbia","Seychelles","Sierra Leone","Singapore","Slovakia","Slovenia","South Africa","South Korea","Spain","Sri Lanka","St Kitts &amp; Nevis","St Lucia","St Vincent","St. Lucia","Sudan","Suriname","Swaziland","Sweden","Switzerland","Syria","Taiwan","Tajikistan","Tanzania","Thailand","Timor L'Este","Togo","Tonga","Trinidad &amp; Tobago","Tunisia","Turkey","Turkmenistan","Turks &amp; Caicos","Uganda","Ukraine","United Arab Emirates","United Kingdom","Uruguay","Uzbekistan","Venezuela","Vietnam","Virgin Islands (US)","Yemen","Zambia","Zimbabwe"];
  76. var cntr = document.getElementById("country");
  77. for(var i=0; i<country_list.length; i++){
  78. var option = document.createElement("option");
  79. if(country_list[i] === "Greece"){
  80. option.value = country_list[i];
  81. option.text = country_list[i];
  82. option.selected = true;
  83. cntr.appendChild(option);
  84. }else{
  85. option.value = country_list[i];
  86. option.text = country_list[i];
  87. cntr.appendChild(option);
  88. }
  89. }
  90.  
  91. }
  92.  
  93.  
  94. function Register(central){
  95. var div = document.createElement("div");
  96. div.id = "myForm";
  97. div.innerHTML = [
  98. '<form method="post">\
  99. <label for="uname">*Username: </label>\
  100. <input pattern=".{8,50}" id="uname" type="text" name=\'Username\' required title="Username must be at least 8 charachters">\
  101. <div id="leftSpace"><label for="email">*email:</label>\
  102. <input pattern="[a-z0-9._%+-]+@[a-z0-9.-]+\.[a-z]{2,13}$" id="email" type="email" name=\'email\' required></div><br><br>\
  103. <label for="password">*Password:</label>\
  104. <input id="password" type="password" placeholder="Password" name=\'Password\' required title="Password must contain at least one charachter one number and one symbol">\
  105. <div id="leftSpace"><label for="confirm_password">*Confirm Password:</label>\
  106. <input id="confirm_password" type="password" placeholder="Confirm Password" name=\'Confirm Password\' required></div><br><br>\
  107. <label for="fname">*First Name:</label>\
  108. <input id="fname" type="text" name=\'First Name\' required>\
  109. <div id="leftSpace"><label for="lname">*Last Name:</label>\
  110. <input id="lname" type="text" name=\'Last Name\' required></div><br><br>\
  111. <label for="bdate">*Birth Date:</label>\
  112. <input id=\'bdate\' type="date" name="bdate" max="2001-12-31">\
  113. <div id="leftSpace"><label for="gender">Gender:</label>\
  114. <input id="Male" type="radio" name="gender" value="male">Male\
  115. <input id="Female" type="radio" name="gender" value="female">Female</div><br><br>\
  116. <label for="country">*Country:</label>\
  117. <select id="country">\
  118. </select>\
  119. <div id="leftSpace"><label for="city">*City:</label>\
  120. <input pattern=".{2,50}" id="city" type="text" name=\'City\' required></div><br><br>\
  121. <div id="centerIt"><label>More Info:</label><br>\
  122. <textarea maxlength="500" id="info" rows="6" cols="50" placeholder="Your text here" ></textarea></div><br><br>\
  123. <input id="submit" type=\'submit\' value=\'Create Account\' onclick="sendAjaxGet();" ><br>\
  124. </form>'
  125. ].join('');
  126. document.getElementById(central).insertBefore(div,null);
  127. countryList();
  128. }
  129.  
  130. function SignIn(central){
  131. var changeDir = document.getElementById("myForm");
  132. while(changeDir.length > 0){
  133. changeDir[0].parentNode.removeChild(changeDir[0]);
  134. }
  135. var div = document.createElement("div");
  136. div.id = "mySignIn";
  137. div.innerHTML = [
  138. '<form method="post">\
  139. <label for="uname">Username: </label>\
  140. <input pattern=".{8,50}" id="uname" type="text" name=\'Username\' required >\
  141. <label for="password">Password:</label>\
  142. <input id="password" type="password" placeholder="Password" name=\'Password\' required >\
  143. <input id="signIn" type=\'submit\' value=\'Sign In\' onclick="sendAjaxGet();" ><br>\
  144. <h2>Don\'t wanna miss a thing..?</h2>\
  145. </form>'
  146. ].join('');
  147. document.getElementById(central).insertBefore(div,null);
  148. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement