html 输入掩码密码_使用输入掩码输入ISO格式的日期并在Microsoft Access中进行完全验证

html 输入掩码密码

输入日期比较棘手 (To enter a date is tricky)

The Date Picker is a safe method to always ensure valid dates to be entered without noisy error messages disturbing the user. However, for many scenarios like accounting and statistics, the Date Picker method is way to slow for the fast-typing user because of the many mouse-clicks needed.

日期选择器是一种始终确保输入有效日期的安全方法,而不会产生嘈杂的错误消息,不会打扰用户。 但是,对于诸如计费和统计之类的许多情况,由于需要大量的鼠标单击,因此对于快速键入用户而言,“日期选择器”方法是一种减慢速度的方法。

Entering a date in a textbox is the fast method but, in case of a typo, navigating in the textbox is not optimal, and the user will meet an unfriendly error message. In many cases, applying an inputmask may help, but not for dates because the validation options are far too limited; you can still easily input day 31 for, say, June and an error message is popped..

在文本框中输入日期是一种快速的方法,但是如果输入错误,则在文本框中导航不是最佳选择,并且用户会遇到不友好的错误消息。 在许多情况下,应用输入掩码可能会有所帮助,但不适用于日期,因为验证选项太有限了。 您仍然可以轻松输入第6天的第31天,然后弹出错误消息。

To sort this out, code is needed. The inputmask adds the option that the code always will know where the user is typing, thus it can prevent and correct many typing errors. For example, if the first month digit is zero, the second month digit can be any digit except zero, but if the first is one, the second can be zero, though not higher than two. And the last day of February is 29 in leap years and not 28 as in common years. Does the user input 2014-02-29, the code will silently correct to 2014-02-28.

为了解决这个问题,需要代码。 inputmask添加了一个选项,使代码始终可以知道用户在哪里键入内容,从而可以防止和纠正许多键入错误。 例如,如果第一个月的数字为零,则第二个月的数字可以是除零以外的任何数字,但是如果第一个月的数字为一,则第二个数字可以为零,但不大于2。 2月的最后一天在is年是29,而不是普通年份的28。 用户是否输入2014-02-29,代码将默默地更正为2014-02-28。

它应该如何工作 (How it should work)

To have a textbox that just works for entering date takes several steps:

要拥有一个仅可用于输入日期的文本框,需要执行以下步骤:

  • Define an input mask that makes sense to the user

    定义对用户有意义的输入掩码
  • Handle positioning of the cursor no matter how the user enters the textbox

    无论用户如何输入文本框,都将处理光标的定位
  • Enable entering of digits no matter how the user navigates in the textbox

    无论用户如何在文本框中导航,都允许输入数字
  • Catch all invalid inputs

    捕获所有无效输入
  • Provide reasonable default values to correct invalid inputs

    提供合理的默认值以更正无效输入
  • Set a format for the textbox

    设置文本框的格式

That may seem like a lot, but the outcome is a highly optimised control demonstrating the true power of an input mask.

这看起来可能很多,但是结果是一个高度优化的控件,展示了输入掩码的真正功能。

正确处理需要很多时间 (It takes a lot to get it right)

The first and the last item are quite simple.

第一项和最后一项非常简单。

The input mask is, as no digit is optional (it is assumed that years must be larger then 1000):

输入掩码是数字,因为没有数字是可选的(假设年份必须大于1000):

"0000/00/00;1;0" “ 0000/00/00; 1; 0”

and the format is:

格式为:

"yyyy/mm/dd" “ yyyy / mm / dd”

This makes the textbox contain as default (where the slash  will be replaced by your local date separator ):

这使文本框默认包含(其中的斜杠将由

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值