ReadyGo!技术成就梦想 >> .Net技术 >> XML&WebService >> 一个类似于calendar日期控件,不用再刷新页面。

一个类似于calendar日期控件,不用再刷新页面。

ReadyGo!技术成就梦想 www.efish.cn efish 2007-10-25 10:15:17
1. 一个类似于calendar日期控件,不用再刷新页面。
2. 判断文本控件里的值是否能转换成日期型。

.htc 例1:
/*
*xpmask.htc
*
*/

//------------------------------------------------------------------------------------------------------

<public:component
lightweight=false
>

<public:defaults
contenteditable=false
tabstop=true
/>

<public:attach event="ondocumentready" onevent="initcoolmask()" />
<public:attach event="ondetach" onevent="cleanupcoolmask()" />

<public:property name="masktype" value="" />
<public:property name="realvalue" value="" />
<public:property name="tooltipstr" value="" />

<script language="vbscript">


sub initcoolmask()
attachevent "onreadystatechange", getref("coolmaskinputblur")
attachevent "onfocus", getref("coolmaskinputfocus")
attachevent "onblur", getref("coolmaskinputblur")
coolmaskinputblur
end sub

sub cleanupcoolmask()
detachevent "onreadystatechange", getref("coolmaskinputblur")
detachevent "onfocus", getref("coolmaskinputfocus")
detachevent "onblur", getref("coolmaskinputblur")
end sub

sub coolmaskinputfocus()
with element
if not .realvalue = "" then .value = .realvalue
.select()
end with
end sub

sub coolmaskinputblur()
with element
select case ucase(.masktype)
case "datetime"
.realvalue = .value
.value = maskdatetime(.value)
.tooltipstr = .tooltip
case "shortdate"
.realvalue = .value
if maskdate(.value, "short") = formatdatetime("1900-1-1 0:00:00", vbshortdate) then
.value = ""
.tooltipstr = "format: yyyy-mm-dd "
else
.value = maskdate(.value, "short")
if not .realvalue = "" then
.tooltipstr = "format: "&.realvalue
else
.tooltipstr = "format: yyyy-mm-dd "
end if
end if
.title =.tooltipstr
case "mediumdate"
.realvalue = .value
.value = maskdate(.value, "medium")
case "longdate"
.realvalue = .value
.value = maskdate(.value, "long")
case "zipcode"
.realvalue = parsechar(.value, array(" ", "-"))
.value = maskzip(.value)
case "phone"
.realvalue = parsechar(.value, array(" ", "(", ")", "-", "."))
.value = maskphone(.value)
case "percent"
.realvalue = parsechar(.value, array(" ", "%"))
.value = maskpercent(.value)
case else
.realvalue = .value
end select
end with
end sub

function parsechar(sstr, schar)
dim i, zchar, snewstr
if typename(schar) = "string" then zchar = array(schar) else zchar = schar
snewstr = sstr
for i = lbound(zchar) to ubound(zchar)
snewstr = replace(snewstr, cstr(zchar(i)), "")
next
parsechar = snewstr
end function

function setviewstate(bstate)
with element
if not bstate then
.runtimestyle.color = .style.color
else
.runtimestyle.color = "red"
end if
end with
end function

function maskdate(svalue, stype)
if isnumeric(svalue) then
"svalue = parsechar(svalue, array(" ", "-", "/", ",", ".", "\", "^", "&", "*", "@", "~", "`", """, "!", "#", "$", "%", "|", "(", ")", "+", "_", "=", ";", "?", ":", "{", "}", "", "<", ">"))
if len(svalue) = 8 then svalue = left(svalue, 4) & "-" & left(right(svalue, 4), 2) & "-" & right(right(svalue, 4), 2)
if len(svalue) = 6 then svalue = left(svalue, 4) & "-0" & left(right(svalue, 2), 1) & "-0" & right(right(svalue, 2), 1)
end if
dim zmonth
zmonth = array("january", "february", "march", "april", "may", "june", "july", "august", "september", "october", "november", "december")
if len(trim(svalue)) = 0 then
maskdate = ""
setviewstate false
elseif not(isdate(svalue)) then
maskdate = "date error"
setviewstate true
else
select case (stype)
case "medium"
maskdate = d
相关文章
一个类似于calendar日期控件,不.. 1. 一个类似于calendar日期控件,不用再刷新页面。 2. 判断文本控件里的值是否能转换成日期型。 .htc 例1:..
一个类似于calendar日期控件,不.. 1. 一个类似于calendar日期控件,不用再刷新页面。 2. 判断文本控件里的值是否能转换成日期型。 .htc 例1:..
1. 一个类似于calendar日期控件,.. 1. 一个类似于calendar日期控件,不用再刷新页面。 2. 判断文本控件里的值是否能转换成日期型。 .htc 例1:..
2秒记住本站域名

玩过泡泡龙吗?Readygo?Go! 再加上.Com.Cn的后缀,那就是大名小顶的ReadyGo.com.cn

分类导航
ReadyGo!技术成就梦想