How to auto format textbox inputs

后端 未结 4 1447
野性不改
野性不改 2020-12-21 23:36

   
      
   <         


        
4条回答
  •  盖世英雄少女心
    2020-12-22 00:05

    I've been watching a project on GitHub (and providing feedback to improve it) for just such kind of formatting called formatter.js http://firstopinion.github.io/formatter.js/demos.html This might be just the thing you're looking for.

    This wouldn't stop you from typing in dates like the 53rd of May... but it will help you format.

    new Formatter(document.getElementById('date-input'), {
      'pattern': '{{99}}/{{99}}/{{9999}}',
      'persistent': true
    });
    

    or

    $('#date-input').formatter({
      'pattern': '{{99}}/{{99}}/{{9999}}',
      'persistent': true
    });
    

提交回复
热议问题