Advertisement
Guest User

MISTMIST123

a guest
Mar 10th, 2019
134
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.96 KB | None | 0 0
  1. function num(str)
  2. {
  3. mone=0;
  4. for(var i=0;i<str.length;i++)
  5. {
  6. if((str.charAt(i)>=1)&&(str.charAt(i)<=9))
  7. mone+=1;
  8. }
  9. if(mone>0)
  10. return true;
  11. else
  12. return false;
  13.  
  14.  
  15. }
  16. function capital(str)
  17. {
  18. mone=0;
  19. for(var i=0;i<str.length;i++)
  20. {
  21. if((str.charAt(i)>='A')&&(str.charAt(i)<='Z'))
  22. mone+=1;
  23. }
  24. if(mone>=2)
  25. return false;
  26. else
  27. return true;
  28.  
  29.  
  30. }
  31.  
  32.  
  33. function check()
  34. {
  35. msg="";
  36.  
  37. firstname=document.rishum.firstname.value;
  38. if(firstname.length==0)
  39. msg=msg+"missing full name \n";
  40. else if(num(firstname))
  41. msg=msg+"there are numbers in firstname \n";
  42.  
  43.  
  44. lastname=document.rishum.lastname.value;
  45. if(lastname.length==0)
  46. msg=msg+"missing last name \n";
  47. else if(num(lastname))
  48. msg=msg+"there are numbers in lastname \n";
  49.  
  50. email=document.rishum.email.value;
  51. if(email.length==0)
  52. msg=msg+"missing email \n";
  53. else
  54. if(email.indexOf('@')<0)
  55. msg=msg+"email is missing @ \n";
  56. if(email.indexOf('.com')<0)
  57. msg=msg+"email is missing .com \n";
  58.  
  59. username=document.rishum.username.value;
  60. if(username.length==0)
  61. msg=msg+"missing user name \n";
  62. else if(!(username.charAt(0)>='A'&&username.charAt(0)<='Z'))
  63. msg=msg+"first letter in user name must be a capital letter \n";
  64. else if(capital(username))
  65. msg=msg+"There must be at least 2 capital letters in username \n";
  66.  
  67. password=document.rishum.password.value;
  68. password2=document.rishum.password2.value;
  69. if(password.length==0)
  70. msg=msg+"missing password \n";
  71. else if(capital(password))
  72. msg=msg+"There must be at least 2 capital letters in password \n";
  73. if(password2.length==0)
  74. msg=msg+"missing password confirmation \n";
  75. if(password.length!=0&&password2.length!=0&&password!=password2)
  76. msg=msg+"password doesn't match to password confirmation \n";
  77.  
  78. if(msg.length==0)
  79. {
  80. alert("you have registered successfully");
  81. return true;
  82. }
  83. else
  84. {
  85. alert("---The next errors were found--- \n\n"+msg);
  86. return false;
  87. }
  88.  
  89.  
  90. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement