Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function num(str)
- {
- mone=0;
- for(var i=0;i<str.length;i++)
- {
- if((str.charAt(i)>=1)&&(str.charAt(i)<=9))
- mone+=1;
- }
- if(mone>0)
- return true;
- else
- return false;
- }
- function capital(str)
- {
- mone=0;
- for(var i=0;i<str.length;i++)
- {
- if((str.charAt(i)>='A')&&(str.charAt(i)<='Z'))
- mone+=1;
- }
- if(mone>=2)
- return false;
- else
- return true;
- }
- function check()
- {
- msg="";
- firstname=document.rishum.firstname.value;
- if(firstname.length==0)
- msg=msg+"missing full name \n";
- else if(num(firstname))
- msg=msg+"there are numbers in firstname \n";
- lastname=document.rishum.lastname.value;
- if(lastname.length==0)
- msg=msg+"missing last name \n";
- else if(num(lastname))
- msg=msg+"there are numbers in lastname \n";
- email=document.rishum.email.value;
- if(email.length==0)
- msg=msg+"missing email \n";
- else
- if(email.indexOf('@')<0)
- msg=msg+"email is missing @ \n";
- if(email.indexOf('.com')<0)
- msg=msg+"email is missing .com \n";
- username=document.rishum.username.value;
- if(username.length==0)
- msg=msg+"missing user name \n";
- else if(!(username.charAt(0)>='A'&&username.charAt(0)<='Z'))
- msg=msg+"first letter in user name must be a capital letter \n";
- else if(capital(username))
- msg=msg+"There must be at least 2 capital letters in username \n";
- password=document.rishum.password.value;
- password2=document.rishum.password2.value;
- if(password.length==0)
- msg=msg+"missing password \n";
- else if(capital(password))
- msg=msg+"There must be at least 2 capital letters in password \n";
- if(password2.length==0)
- msg=msg+"missing password confirmation \n";
- if(password.length!=0&&password2.length!=0&&password!=password2)
- msg=msg+"password doesn't match to password confirmation \n";
- if(msg.length==0)
- {
- alert("you have registered successfully");
- return true;
- }
- else
- {
- alert("---The next errors were found--- \n\n"+msg);
- return false;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement