<public:component tagName=dtPicker>
<public:attach event="oncontentready" onevent="fnInit"/>
<public:attach event="onfocus" onevent="fnFocus" />
<public:attach event="onfocusout" onevent="fnFocusOut" />
<public:attach event="onkeypress" onevent="fnKeyPress" />
<public:method name="getDate" />
<public:method name="setDate" />
<public:property name="retDate" />
<public:property name="insDate" />
</public:component>

<script language=vbscript>
Function fnInit()
	element.style.border = "lightgrey 2px inset"
	element.value = FormatDateTime(Date, vbShortDate)
End Function

Function fnKeyPress()
	Dim fooValue
	fooValue = element.value
		If window.event.keyCode = 13 Then
			If Not IsDate(fooValue) Then
				MsgBox "Введенное значение не является датой", vbOKOnly+vbCritical,"Ошибка ввода данных"
				element.focus
			Else
				insDate = fooValue
				Call setDate()
			End If
		Else
			Exit Function
		End If
End Function

Function fnFocusOut()
	Dim fooValue
	fooValue = element.value
	If Not IsDate(fooValue) Then
		MsgBox "Введенное значение не является датой", vbOKOnly+vbCritical,"Ошибка ввода данных"
		element.focus
	Else
		insDate = fooValue
		Call setDate()
	End If
End Function

Function getDate()
	retDate = FormatDateTime(element.value, vbShortDate)
End Function

Function setDate()
	If Not IsDate(insDate) Then Exit Function
	element.value = FormatDateTime(insDate, vbShortDate)
End Function

Function fnFocus()
	element.select 
End Function
</script>
