限时优惠活动
亲爱的苦力吧用户,我们为了回馈新老用户一直以来的鼎力支持,即日起(2025-02-06至2025-03-06)凡是购买苦力吧VIP/充值K币的新老用户,都直接可获得买一送一的优惠馈赠。例如:购买一个月的VIP会员可直接获得两个月的VIP会员;充值100K币可直接获得200K币,以此类推!有任何疑问可联系在线客服,感谢各位用户对苦力吧素材的信任与厚爱,我们将一如既往的给大家上新更多优质的素材源码,祝大家开工大吉、工作顺利、心想事成。

html5+css创建的登录注册页表单提交模板

所属分类: html模板-表单提交    2024-12-27 11:37:56

html5+css创建的登录注册页表单提交模板 ie兼容6
 查看演示  登录后下载 温馨提示
登录会员即可享受免费下载
 我要建站

html5+css创建的登录注册页表单提交模板(共3个文件)

    • index.html

使用方法

  • code
  • source
  1. const frmSignIn = document.getElementById('frmSignIn');
  2. const frmForget = document.getElementById('frmForget');
  3. const frmRegister = document.getElementById('frmRegister');
  4. const inputs = document.querySelectorAll('.asm-form__input');
  5. const showPasswordTogglers = document.querySelectorAll('[data-action="toggle-show-password"]');
  6. const linkButtons = document.querySelectorAll('[data-action="show-form"]');
  7. /* Functions */
  8. const inputLabelFocusOut = event => {
  9. label = document.querySelector(`label[for="${event.target.id}"]`);
  10. if(event.target.value.length >0 ) {
  11. label.classList.add('active');
  12. label.parentNode.classList.remove('invalid');
  13. } else {
  14. label.classList.remove('active');
  15. }
  16. }
  17. const inputLabelFocus = event => {
  18. label = document.querySelector(`label[for="${event.target.id}"]`);
  19. label.classList.add('active');
  20. label.parentNode.classList.remove('invalid');
  21. }
  22. const toggleShowPassword = event => {
  23. const input = document.querySelector(event.target.dataset.input);
  24. const type = input.getAttribute('type');
  25. input.setAttribute('type', type==='password'?'text':'password');
  26. }
  27. const showForm = event => {
  28. event.preventDefault();
  29. for (const form of document.querySelectorAll('.asm-form')) {
  30. form.classList.remove('active');
  31. }
  32. for (const error of document.querySelectorAll('.asm-form__inputbox.invalid')) {
  33. error.classList.remove('invalid');
  34. }
  35. document.querySelector(event.target.dataset.target).classList.add('active');
  36. }
  37. /* Listener assigns */
  38. for (const input of inputs) {
  39. input.addEventListener('focusout', inputLabelFocusOut);
  40. input.addEventListener('focus', inputLabelFocus);
  41. }
  42. for (const toggler of showPasswordTogglers) {
  43. toggler.addEventListener('click', toggleShowPassword);
  44. }
  45. for (const button of linkButtons) {
  46. button.addEventListener('click', showForm);
  47. }
  48. /* Form Validator*/
  49. const validateForm = form => {
  50. const inputs = form.querySelectorAll('.validate');
  51. for (const input of inputs) {
  52. input.classList.remove('invalid');
  53. input.parentNode.classList.remove('invalid');
  54. let allOK = true;
  55. switch (input.dataset.validation) {
  56. case 'regex': {
  57. allOK = input.value.match(new RegExp(input.dataset.regex));
  58. break;
  59. }
  60. case 'match': {
  61. allOK = input.value === form.querySelector(input.dataset.target).value;
  62. break;
  63. }
  64. default: {
  65. allOK = false;
  66. break;
  67. }
  68. } //end of switch
  69. if (!allOK) {
  70. input.classList.add('invalid');
  71. input.parentNode.classList.add('invalid');
  72. return false;
  73. }
  74. } //end of for-of
  75. }
const frmSignIn = document.getElementById('frmSignIn');
const frmForget = document.getElementById('frmForget');
const frmRegister = document.getElementById('frmRegister');

const inputs = document.querySelectorAll('.asm-form__input');
const showPasswordTogglers = document.querySelectorAll('[data-action="toggle-show-password"]');
const linkButtons = document.querySelectorAll('[data-action="show-form"]');

/* Functions */
const inputLabelFocusOut = event => {
  label = document.querySelector(`label[for="${event.target.id}"]`);
  if(event.target.value.length >0 ) {
    label.classList.add('active');
    label.parentNode.classList.remove('invalid');
  } else {
    label.classList.remove('active');    
  }
}

const inputLabelFocus = event => {
  label = document.querySelector(`label[for="${event.target.id}"]`);
  label.classList.add('active');
  label.parentNode.classList.remove('invalid');
}

const toggleShowPassword = event => {
  const input = document.querySelector(event.target.dataset.input);
  const type = input.getAttribute('type');
  input.setAttribute('type', type==='password'?'text':'password');
}

const showForm = event => {
  event.preventDefault();
  
  for (const form of document.querySelectorAll('.asm-form')) {
    form.classList.remove('active');
  }
  
  for (const error of document.querySelectorAll('.asm-form__inputbox.invalid')) {
    error.classList.remove('invalid');
  }
  
  document.querySelector(event.target.dataset.target).classList.add('active');
}

/* Listener assigns */

for (const input of inputs) {
  input.addEventListener('focusout', inputLabelFocusOut);
  input.addEventListener('focus', inputLabelFocus);
}

for (const toggler of showPasswordTogglers) {
  toggler.addEventListener('click', toggleShowPassword);
}

for (const button of linkButtons) {
  button.addEventListener('click', showForm);
}

/* Form Validator*/

const validateForm = form => {
  const inputs = form.querySelectorAll('.validate');
  for (const input of inputs) {

    input.classList.remove('invalid');
    input.parentNode.classList.remove('invalid');

    let allOK = true;

    switch (input.dataset.validation) {
      case 'regex': {
        allOK = input.value.match(new RegExp(input.dataset.regex));
        break;
      }
      case 'match': {
        allOK = input.value === form.querySelector(input.dataset.target).value;
        break;
      }
      default: {
        allOK = false;
        break;
      }
    } //end of switch

    if (!allOK) {
      input.classList.add('invalid');
      input.parentNode.classList.add('invalid');
      return false;
    }
  } //end of for-of
  
}

站长提示:
1. 苦力吧素材官方QQ群:950875342
2. 平台上所有素材资源,需注册登录会员方能正常下载。
3. 会员用户积极反馈网站、素材资源BUG或错误问题,每次奖励2K币
4. PHP源码类素材,如需协助安装调试,或你有二次开发需求,可联系苦力吧客服。
5. 付费素材资源,需充值后方能下载,如有任何疑问可直接联系苦力吧客服
相关资源 / 表单提交

html5响应式怀旧老式风格后台登录页模板

一款蓝色风格后台系统登录模板,采用table布局设计,青春怀旧风格。
  表单提交
 2171  0

html5响应式带验证码后台登录模板

一款后台系统登录页模板,带tab选项卡切换登录及验证码切换功能。
  表单提交
 2243  0

html5高仿清华大学艺术博物馆登录页模板

一款响应式高大上的会员登录模板,大学博物馆会员登录页面。
  表单提交
 8235  0

html5响应式蓝色动画会员登录模板

一款蓝色动态动画响应式登录页面模板,左侧文字说明,右侧为用户登录表单,用户和密码输入框。
  表单提交
 7437  0

评论数(0) 回复有机会获得K币 用户协议

^_^ 还没有人评论,快来抢个沙发!
😀
  • 😀
  • 😊
  • 😂
  • 😍
  • 😑
  • 😷
  • 😵
  • 😛
  • 😣
  • 😱
  • 😋
  • 😎
  • 😵
  • 😕
  • 😶
  • 😚
  • 😜
  • 😭
发表评论