<input onpropertychange="if(isNaN(Number(this.value))){alert();this.focus()}">
解决方案 »
- Button的OnClientClick事件问题
- 2K3/IIS6,支持ASP.NET,为什么不能像Godaddy那样放个web.config来做301定向?
- 在 ASP.NET 中执行 URL 重写 帮帮忙
- 谁能发个代码混淆器
- GridView显示问题。
- 求一个用DIV+CSS+JS的导航二级菜单(要横向的)!
- 关于Microsoft Visual Studio .NET 2003问题
- 取得一个IP,然后如何判断此IP下是否是局域网的机子?(网站建设问题)
- 如何声明一个变量在任何一个aspx页面中均可取值和赋值?在哪声明?
- 怎样防止刷新?
- 控件属性问题。。。
- 关于DateGrid中列隐藏的问题
感觉客户端压力很大,只不过没关系
//是否数字字符串
public static bool IsNumber(string inputData)
{
Match m = _isNumber.Match(inputData);
return m.Success;
}
private string text;
public Form1()
{
text = textBox1.Text;
}
private void textBox1_TextChanged(object sender, System.EventArgs e)
{
int len = text.Length;
if(len < textBox1.Text.Length)
{
int index = textBox1.Text.IndexOf(text);
char c = (textBox1.Text.Remove(index,text.Length))[0];
if(c.CompareTo('0') < 0||c.CompareTo('9') >0)
{
textBox1.Text = text;
textBox1.SelectionStart = text.Length;
}
}
text = textBox1.Text;
}
private System.Windows.Forms.TextBox textBox1;
private string text;
public Form1()
{
text = textBox1.Text;
}
private void textBox1_TextChanged(object sender, System.EventArgs e)
{
int len = text.Length;
if(len < textBox1.Text.Length)
{
int index = textBox1.Text.IndexOf(text);
char c = (textBox1.Text.Remove(index,text.Length))[0];
if(c.CompareTo('0') < 0||c.CompareTo('9') >0)
{
textBox1.Text = text;
textBox1.SelectionStart = text.Length;
}
}
text = textBox1.Text;
}
靠正则表达式判断
正确!
AutoPostBack 设为true