Mask input is a common control. I remember the first time I saw this control in Visual FoxPro! I feel very functional and good. Now, when using C # To Develop ASP. NET applications, you also need to use this input control. However, because the mask text box function in Visual FoxPro is too powerful, I am not afraid to do it at the moment. There are also some self-made features on the Internet, such as: http://www.weste.net/2004/11-25/09162561988.html, but the features are not very good. Later in the http://www.stedy.com saw their mask text box, feel this method is very suitable for the Web application, the client code down! (Stedy software is a product that costs money! And it is expensive. 79.99 USD, ft .)
Analyzed the stedy client script (VBScript), which provides a client method for each mask rule. The following is the client script code formatted with the date mask:
Function maskDate (sValue, sType)
Dim zMonth
ZMonth = array ("January", "February", "March", "0000l", "May", "June", "July", "August", "September ", "October", "November", "December ")
If len (trim (sValue) = 0 then
MaskDate = ""
SetViewState false
Elseif not (isDate (sValue) then
MaskDate = "# invalid date entered #"
SetViewState true
Else
Select case (sType)
Case "medium"
MaskDate = day (dateValue (sValue) & "-" & left (zMonth (month (dateValue (sValue)-1), 3) & "-" & year (dateValue (sValue ))
Case "long"
MaskDate = zMonth (month (dateValue (sValue)-1) & "" & day (dateValue (sValue) & "," & year (dateValue (sValue ))