scripts.js 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. jQuery(document).ready(function() {
  2. $('.container .form .username, .container .form .code, .container .form .password, .container .form .repassword').keyup(function(){
  3. $(this).parent().find('.error').fadeOut('fast');
  4. });
  5. });
  6. function verify_click () {
  7. var that = $('.container .form');
  8. var username = $(that).find('.username').val();
  9. if(username == '') {
  10. $(that).find('.error').fadeOut('fast', function(){
  11. $(this).css('top', '27px');
  12. });
  13. $(that).find('.error').fadeIn('fast', function(){
  14. $(that).find('.username').focus();
  15. });
  16. return false;
  17. }
  18. verify(username);
  19. }
  20. function register_click() {
  21. var that = $('.container .form');
  22. var code = document.getElementById('code').value;
  23. var username = $(that).find('.username').val();
  24. var password = $(that).find('.password').val();
  25. var re_password = $(that).find('.repassword').val();
  26. console.log(username, password, re_password, code);
  27. if(username == '') {
  28. $(that).find('.error').fadeOut('fast', function(){
  29. $(this).css('top', '27px');
  30. });
  31. $(that).find('.error').fadeIn('fast', function(){
  32. $(that).find('.username').focus();
  33. });
  34. return false;
  35. }
  36. if(code == '') {
  37. console.log("code is ", code);
  38. $(that).find('.error').fadeOut('fast', function(){
  39. $(this).css('top', '96px');
  40. });
  41. $(that).find('.error').fadeIn('fast', function(){
  42. $(that).find('.code').focus();
  43. });
  44. return false;
  45. }
  46. if(password == '') {
  47. $(that).find('.error').fadeOut('fast', function(){
  48. $(this).css('top', '165px');
  49. });
  50. $(that).find('.error').fadeIn('fast', function(){
  51. $(that).find('.password').focus();
  52. });
  53. return false;
  54. }
  55. if(password !== re_password) {
  56. console.log(password, re_password);
  57. $(that).find('.error').fadeOut('fast', function(){
  58. $(this).css('top', '234px');
  59. });
  60. $(that).find('.error').fadeIn('fast', function(){
  61. $(that).find('.repassword').focus();
  62. });
  63. return false;
  64. }
  65. register(username, password, code);
  66. };