Advertisement
Guest User

Untitled

a guest
Mar 28th, 2017
146
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.01 KB | None | 0 0
  1. $("#register").click(function() {
  2. var username = $("#register-username").val();
  3. var password = $("#register-password").val();
  4. var confirmPassword = $("#confirm-password").val();
  5. var data = {};
  6.  
  7. if (/[a-zA-Z0-9_]+/.test(username) == false) {
  8. data = { type: "failure", info: "usernameInvalid" };
  9. } else if (/[a-zA-Z0-9_]+/.test(password) == false) {
  10. data = { type: "failure", info: "passwordInvalid" };
  11. } else {
  12. if (username.length >= 5) {
  13. if (password.length >= 6) {
  14. if (password == confirmPassword) {
  15. data = { type: "success", info: "registerSuccessful", user: username, password: password, confirm: confirmPassword };
  16. } else {
  17. data = { type: "failure", info: "passwordMismatch" };
  18. }
  19. } else {
  20. data = { type: "failure", info: "passwordLength" };
  21. }
  22. } else {
  23. data = { type: "failure", info: "usernameLength" };
  24. }
  25. }
  26.  
  27. socket.emit("register", data);
  28. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement