script.js 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. $('#registerInputUsername1')
  2. .change(function(e) {
  3. var inputUsername = $(this);
  4. var username = inputUsername.val();
  5. var re = /^[A-Za-z][A-Za-z0-9_]+$/;
  6. var isUsernameValid = username.match(re);
  7. if(! isUsernameValid) {
  8. inputUsername
  9. .addClass('is-invalid')
  10. .removeClass('is-valid');
  11. return;
  12. }
  13. $.get(
  14. 'http://localhost:3001/username-check?username=' + username,
  15. function(response) {
  16. console.log(response.success)
  17. if(response.success) {
  18. inputUsername
  19. .addClass('is-valid')
  20. .removeClass('is-invalid');
  21. }
  22. else {
  23. inputUsername
  24. .addClass('is-invalid')
  25. .removeClass('is-valid');
  26. return;
  27. }
  28. }
  29. );
  30. });
  31. var onglets = $('#onglets li a');
  32. onglets.click(function(e) {
  33. var link = $(this);
  34. onglets.removeClass('active');
  35. link.addClass('active');
  36. var idPanneau = link.data('tab-id');
  37. $('.tab').hide();
  38. $('#' + idPanneau).show();
  39. });