login.js 715 B

12345678910111213141516171819202122232425
  1. $(document).ready(function () {
  2. //输入框聚焦
  3. $('.input').focus(function () {
  4. $(this).closest('.modelItem').addClass('active');
  5. });
  6. //输入框失焦
  7. $('.input').blur(function () {
  8. $(this).closest('.modelItem').removeClass('active');
  9. });
  10. //限制输入框不能输入空格跟汉字
  11. $('.input').on('input', function () {
  12. var inputValue = $(this).val();
  13. var sanitizedValue = sanitizeInput(inputValue);
  14. $(this).val(sanitizedValue);
  15. });
  16. function sanitizeInput(input) {
  17. // 替换空格和汉字为空字符串
  18. var sanitizedInput = input.replace(/\s+|[\u4e00-\u9fa5]+/g, '');
  19. return sanitizedInput;
  20. }
  21. });