html:javascript:
function checkStr(obj)
{
strValue = obj.value;
if(strValue != "" && strValue != null)
{
for(var i = 0;i < strValue.length ; i++)
{
if(strValue .charAt(0) < "0" || strValue .charAt(0) > "9")
{
window.alert("只能输入数字!");
obj.focus();
return false;
}
}
}
}
Page_Load():
TextBox1.Attributes["onblur"] = "checkStr(this)";
TextBox1.Attributes["onblur"] = "checkStr(this)";
function checkStr(obj)
{
strValue = obj.value;
if(strValue != "" && strValue != null)
{
for(var i = 0;i < strValue.length ; i++)
{
if(strValue .charAt(0) < "0" || strValue .charAt(0) > "9")
{
window.alert("只能输入数字!");
obj.focus();
return false;
}
}
}
}
Page_Load():
TextBox1.Attributes["onblur"] = "checkStr(this)";
TextBox1.Attributes["onblur"] = "checkStr(this)";

飘过~~