registration.js 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. function Login(){
  2. window.location.href='/login';
  3. };
  4. $(function (){
  5. var username = $("input[name='username']");
  6. var password = $("input[name='password']");
  7. var confirmpwd = $("input[name='confirmpwd']");
  8. var status = false;
  9. var form = $("form");
  10. username.blur(function(){
  11. $.get("/check_username","username="+username.val(),function(resText){
  12. if(resText.errMsg){
  13. $("#firstname-span").text("This username is already registered");
  14. status = false;
  15. }else{
  16. $("#firstname-span").text("");
  17. status = true;
  18. };
  19. },'json');
  20. });
  21. confirmpwd.blur(function(){
  22. var span = $("#password-span");
  23. if(password.val() != confirmpwd.val()){
  24. span.text("Passwords does not match");
  25. status = false;
  26. }else{
  27. span.text("");
  28. status = true;
  29. };
  30. });
  31. form.submit(function(){
  32. if((status == true) && (password.val() != '') && (confirmpwd.val() != '')){
  33. return true;
  34. }else{
  35. alert("Please type your infomation");
  36. return false;
  37. };
  38. });
  39. });