private int
GetFieldLength(string Field)
{
/*int len=0;
foreach(char ch in Field)
{
len+=sizeof(ch);
}*/
int len = System.Text.Encoding.Default.GetByteCount(Field);
return len;
//return len;
}
private bool
IsFieldValid(string field, ref string msg)
{
//\ / : * ? " < >
foreach (char ch in field)
{
if ((ch == '\'' || ch == '"' || ch == '\t' || ch == ':' || ch == '&' || ch == '\\' || ch == '/' || ch == '*' || ch == '?' || ch == '<' || ch == '>'))
{
if (ch == '\'')
{
msg = "存在非法字符" + "\\'";
}
else if (ch == '\\')
{
msg = "存在非法字符" + "\\\\";
}
else
{
msg = "存在非法字符" + ch;
}
return false;
}
}
return true;
}
<input id="TxBox_Time" runat="server" maxlength="10" readonly="readOnly" name="date" onfocus="setday(this)" style="width: 235px" />