How to do date masking using javascript (without JQuery)?

后端 未结 4 610
太阳男子
太阳男子 2020-12-09 00:26


        
4条回答
  •  遥遥无期
    2020-12-09 00:58

    This works quite well (tried it in console on the jquery mask page)

     if (locale !=='' && locale==='zh_CN') {
              $('#text12').mask('9999年99月99日');
              }
              else {
              $('#text12').mask('99/99/9999');
              }
    

    but if you want the mask format to show up in the input field you need to pass it as placeholder attribute

    $('#text12').attr('placeholder', '9999年99月99日')
    

    hope this helps

提交回复
热议问题