bind.js 1.2 KB

1234567891011121314151617181920212223242526272829303132333435
  1. $(document).ready(function() {
  2. $('#project').blur(function () {
  3. if ($(this).val() == '') {
  4. $('#project_name').text('');
  5. } else {
  6. const pcode = getLocalCache('project_code');
  7. if ($(this).val() !== pcode) {
  8. const pc = $(this).val();
  9. $.ajax({
  10. type: 'get',
  11. url: '/project/name',
  12. data: { code: pc },
  13. dataType: 'json',
  14. success: function (result) {
  15. setLocalCache('project_code', pc);
  16. if (result.err === 1) {
  17. $('#project_name').text('');
  18. $('#forget-project').val('');
  19. toast(result.msg, 'error', 'exclamation-circle');
  20. } else {
  21. $('#project_name').text(result.data);
  22. }
  23. }
  24. })
  25. }
  26. }
  27. });
  28. $('input').focus(function () {
  29. if($(this).hasClass('is-invalid')) {
  30. $(this).removeClass('is-invalid');
  31. $(this).siblings('div.invalid-feedback').html('');
  32. }
  33. });
  34. });