I want to validate a text box
我想验证一个文本框
where the user enters the date in format dd/mm
用户以dd / mm格式输入日期
and time hh/mm
和时间hh / mm
in the same text box
在同一文本框中
how to do this?
这该怎么做?
1 个解决方案
#1
There is no simple way to achieve this. There are a couple of complicated ways.
没有简单的方法来实现这一目标。有几种复杂的方法。
You can make the control unbound, then write a handler for the After Update event of the control. In this handler, you will need to validate the user's entry, create a date value from the entry (presumably defaulting the year to the current year), and assign that value to the field storing the date. In addition, you will need an OnCurrent event on the form, where you will set the value of the unbound control to be the appropriately-formatted text version of the date of the current record.
您可以使控件解除绑定,然后为控件的After Update事件编写处理程序。在此处理程序中,您需要验证用户的条目,从条目创建日期值(可能是将年份默认为当前年份),并将该值分配给存储日期的字段。此外,您需要在表单上使用OnCurrent事件,您将在其中将未绑定控件的值设置为当前记录日期的适当格式的文本版本。
Note that this method won't work in a Continuous form, only on a Single Form.
请注意,此方法不能以连续形式工作,只能在单个表单上工作。
#1
There is no simple way to achieve this. There are a couple of complicated ways.
没有简单的方法来实现这一目标。有几种复杂的方法。
You can make the control unbound, then write a handler for the After Update event of the control. In this handler, you will need to validate the user's entry, create a date value from the entry (presumably defaulting the year to the current year), and assign that value to the field storing the date. In addition, you will need an OnCurrent event on the form, where you will set the value of the unbound control to be the appropriately-formatted text version of the date of the current record.
您可以使控件解除绑定,然后为控件的After Update事件编写处理程序。在此处理程序中,您需要验证用户的条目,从条目创建日期值(可能是将年份默认为当前年份),并将该值分配给存储日期的字段。此外,您需要在表单上使用OnCurrent事件,您将在其中将未绑定控件的值设置为当前记录日期的适当格式的文本版本。
Note that this method won't work in a Continuous form, only on a Single Form.
请注意,此方法不能以连续形式工作,只能在单个表单上工作。