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 password = document.getElementById("password").value;
- var confirm_password = document.getElementById("confirm_password").value;
- if(fname.length>20 || fname.length<3){
- event.preventDefault();
- alert("Name must be 3-20 characters");
- document.getElementById("fname").focus();
- return false;
- }else{
- if (!(/^[a-zA-Z]+$/.test(fname))){
- event.preventDefault();
- alert("Name must contain only letters");
- document.getElementById("fname").focus();
- return false;
- }
- }
- if(password !== confirm_password) {
- event.preventDefault();
- alert("Passwords not match");
- document.getElementById("password").focus();
- return false;
- }
- if(lname.length>20 || lname.length<4){
- event.preventDefault();
- alert("Last Name must be 4-20 characters");
- document.getElementById("lname").focus();
- return false;
- }else{
- if (!(/^[a-zA-Z]+$/.test(lname))){
- event.preventDefault();
- alert("Last Name must contain only letters");
- document.getElementById("lname").focus();
- return false;
- }
- }
- if(password.length<6 || password.length>10){
- event.preventDefault();
- alert("Password must be 6-20 characters");
- document.getElementById("password").focus();
- return false;
- }
- if(checkPasswordValidity(password)){
- sendAjaxPOST1();
- }
- return true;
- }
- function checkPasswordValidity(password){
- event.preventDefault();
- console.log("mphke sth for");
- var splChars = /[*|,\":<>{}`\';()@&$#%]/;
- if (!(splChars.test(password))){
- console.log("mphke sth if1");
- event.preventDefault();
- alert("Password must contain at least one letter,one number and one symbol");
- document.getElementById("password").focus();
- return false;
- }
- if(!(/[a-zA-Z]/.test(password))){
- console.log("mphke sth if2");
- event.preventDefault();
- alert("Password must contain at least one letter,one number and one symbol");
- document.getElementById("password").focus();
- return false;
- }
- if(!(/[0-9]/.test(password))){
- console.log("mphke sth if3");
- event.preventDefault();
- alert("Password must contain at least one letter,one number and one symbol");
- document.getElementById("password").focus();
- return false;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement