Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function sendAjaxGet() {
- var uname = document.getElementById('uname').value;
- var email = document.getElementById('email').value;
- var fname = document.getElementById('fname').value;
- var lname = document.getElementById('lname').value;
- var bdate = document.getElementById('bdate').value;
- var city = document.getElementById('city').value;
- var password = document.getElementById("password").value;
- var confirm_password = document.getElementById("confirm_password").value;
- var splChars = "*|,\":<>[]{}`\';()@&$#%";
- var xhr = new XMLHttpRequest();
- if(fname.length>20 || fname.length<3){
- alert("Name must be 3-20 characters");
- document.getElementById("fname").focus();
- event.preventDefault();
- }else{
- if (!(/^[a-zA-Z]+$/.test(fname))){
- alert("Name must contain only letters");
- document.getElementById("fname").focus();
- event.preventDefault();
- }
- }
- if(lname.length>20 || lname.length<4){
- alert("Last Name must be 4-20 characters");
- document.getElementById("lname").focus();
- event.preventDefault();
- }else{
- if (!(/^[a-zA-Z]+$/.test(lname))){
- alert("Last Name must contain only letters");
- document.getElementById("lname").focus();
- event.preventDefault();
- }
- }
- if(password.length<6 || password.length>10){
- alert("Password must be 3-20 characters");
- document.getElementById("password").focus();
- event.preventDefault();
- }else{
- for (var i = 0; i < password.length; i++) {
- if (splChars.indexOf(password.length.charAt(i)) === -1){
- alert("Password must contain at least one letters,one number and one symbol");
- document.getElementById("password").focus();
- event.preventDefault();
- }
- if(!(/^[a-zA-Z]+$/.test(lname))){
- alert("Password must contain at least one letters,one number and one symbol");
- document.getElementById("password").focus();
- event.preventDefault();
- }
- if(!(/^[0-9]+$/.test(lname))){
- alert("Password must contain at least one letters,one number and one symbol");
- document.getElementById("password").focus();
- event.preventDefault();
- }
- }
- }
- if(password !== confirm_password) {
- alert("Passwords not match");
- event.preventDefault();
- } else {
- confirm_password.setCustomValidity('');
- }
- event.preventDefault();
- }
- function countryList(){
- var country_list = ["Afghanistan","Albania","Algeria","Andorra","Angola","Anguilla","Antigua & Barbuda","Argentina","Armenia","Aruba","Australia","Austria","Azerbaijan","Bahamas","Bahrain","Bangladesh","Barbados","Belarus","Belgium","Belize","Benin","Bermuda","Bhutan","Bolivia","Bosnia & 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 & Miquelon","Samoa","San Marino","Satellite","Saudi Arabia","Senegal","Serbia","Seychelles","Sierra Leone","Singapore","Slovakia","Slovenia","South Africa","South Korea","Spain","Sri Lanka","St Kitts & Nevis","St Lucia","St Vincent","St. Lucia","Sudan","Suriname","Swaziland","Sweden","Switzerland","Syria","Taiwan","Tajikistan","Tanzania","Thailand","Timor L'Este","Togo","Tonga","Trinidad & Tobago","Tunisia","Turkey","Turkmenistan","Turks & Caicos","Uganda","Ukraine","United Arab Emirates","United Kingdom","Uruguay","Uzbekistan","Venezuela","Vietnam","Virgin Islands (US)","Yemen","Zambia","Zimbabwe"];
- var cntr = document.getElementById("country");
- for(var i=0; i<country_list.length; i++){
- var option = document.createElement("option");
- if(country_list[i] === "Greece"){
- option.value = country_list[i];
- option.text = country_list[i];
- option.selected = true;
- cntr.appendChild(option);
- }else{
- option.value = country_list[i];
- option.text = country_list[i];
- cntr.appendChild(option);
- }
- }
- }
- function Register(central){
- var div = document.createElement("div");
- div.id = "myForm";
- div.innerHTML = [
- '<form method="post">\
- <label for="uname">*Username: </label>\
- <input pattern=".{8,50}" id="uname" type="text" name=\'Username\' required title="Username must be at least 8 charachters">\
- <div id="leftSpace"><label for="email">*email:</label>\
- <input pattern="[a-z0-9._%+-]+@[a-z0-9.-]+\.[a-z]{2,13}$" id="email" type="email" name=\'email\' required></div><br><br>\
- <label for="password">*Password:</label>\
- <input id="password" type="password" placeholder="Password" name=\'Password\' required title="Password must contain at least one charachter one number and one symbol">\
- <div id="leftSpace"><label for="confirm_password">*Confirm Password:</label>\
- <input id="confirm_password" type="password" placeholder="Confirm Password" name=\'Confirm Password\' required></div><br><br>\
- <label for="fname">*First Name:</label>\
- <input id="fname" type="text" name=\'First Name\' required>\
- <div id="leftSpace"><label for="lname">*Last Name:</label>\
- <input id="lname" type="text" name=\'Last Name\' required></div><br><br>\
- <label for="bdate">*Birth Date:</label>\
- <input id=\'bdate\' type="date" name="bdate" max="2001-12-31">\
- <div id="leftSpace"><label for="gender">Gender:</label>\
- <input id="Male" type="radio" name="gender" value="male">Male\
- <input id="Female" type="radio" name="gender" value="female">Female</div><br><br>\
- <label for="country">*Country:</label>\
- <select id="country">\
- </select>\
- <div id="leftSpace"><label for="city">*City:</label>\
- <input pattern=".{2,50}" id="city" type="text" name=\'City\' required></div><br><br>\
- <div id="centerIt"><label>More Info:</label><br>\
- <textarea maxlength="500" id="info" rows="6" cols="50" placeholder="Your text here" ></textarea></div><br><br>\
- <input id="submit" type=\'submit\' value=\'Create Account\' onclick="sendAjaxGet();" ><br>\
- </form>'
- ].join('');
- document.getElementById(central).insertBefore(div,null);
- countryList();
- }
- function SignIn(central){
- var changeDir = document.getElementById("myForm");
- while(changeDir.length > 0){
- changeDir[0].parentNode.removeChild(changeDir[0]);
- }
- var div = document.createElement("div");
- div.id = "mySignIn";
- div.innerHTML = [
- '<form method="post">\
- <label for="uname">Username: </label>\
- <input pattern=".{8,50}" id="uname" type="text" name=\'Username\' required >\
- <label for="password">Password:</label>\
- <input id="password" type="password" placeholder="Password" name=\'Password\' required >\
- <input id="signIn" type=\'submit\' value=\'Sign In\' onclick="sendAjaxGet();" ><br>\
- <h2>Don\'t wanna miss a thing..?</h2>\
- </form>'
- ].join('');
- document.getElementById(central).insertBefore(div,null);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement