Enter the text box using the C # development mask

Source: Internet
Author: User

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 ))

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.