Auto-format structured data (phone, date) using jQuery plugin (or failing that vanilla JavaScript)

前端 未结 2 1798
无人共我
无人共我 2020-12-15 17:58

I like jQuery and I was wondering if anyone have used a good plugin or (non-jQuery) JavaScript library that allows for auto-formatting of structured fields like phone number

相关标签:
2条回答
  • 2020-12-15 18:20

    Does the Masked Input plugin do what you need or that one you have already found to be unreliable?

    0 讨论(0)
  • 2020-12-15 18:29

    Allan,

    I do believe your best bet would be to use regular expressions inside of two separate formatting methods in order to achieve the desired results. This will be rather straight forward for phone numbers and I'll post a code example if one isn't posted by the time I sit back and have 10 minutes straight to write something up. Perhaps for the date field, you can use something like the jQuery UI Datepicker instead? http://marcgrabanski.com/pages/code/jquery-ui-datepicker

    HTH,

    /sf

    0 讨论(0)
提交回复
热议问题