Mask input is a commonly used control, I remember that this control is in Visual FoxPro! It feels strong, nice. Now use C # development ASP.NET applications, you need to use this input control, just do one yourself. But because the mask text box in Visual FoxPro is too strong, I still don't dare to do it for a while. There are also some homemade online, such as http://www.weste.net/2004/11-25/09162561988.html, but feeling is not very suitable. Later, I saw the mask text boxes they did in http://www.stedy.com, I feel that this way is very suitable in the web application, I will down the client code DOWN! (STEDY Software is a product, it is necessary to spend money! And very expensive 79.99USD, ft.) Analyze STEDY client scripts (VBScript) They make a client method for each mask rule. The following is a client script code formatted by the date mask:
Function Maskdate (Svalue, Stype)
DIM ZMONTH
Zmonth = Array ("January", "February", "March", "April", "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) & "-" & left (zmonth (Month (Svalue) - 1), 3) & "-" & Year (DateValue (SVALUE))
Case "long"
Maskdate = zmonth (Month (Svalue) - 1) & "& Day (DateValue) &", "& Year (DateValue (Svalue))
Case Else
Maskdate = formatdatetime (svalue, vbshortdate)
End SELECT
SetViewState False
END IF
END FUNCTION
It can be seen that the processing mode is formatted in the text box, and if the format is successful, it appears as a formatted string, otherwise, "# invalid date entered" is displayed. Other methods are like maskcurrency, what is Maskssn. The MaskTextBox client has two custom properties
{
Output.writebegintag ("input");
Output.writeAttribute ("Type", "Hidden");
Output.writeAttribute ("Value", "");
Output.writeAttribute ("ID", "__" this.uniqueID);
Output.writeAttribute ("Name", "__" this.uniqueID);
Output.write (htmltextwriter.tagrightchar);
Base.Render (Output);
}