怎么样把输入框设置成只容许数字输入? 在.net framework1.1中,怎么样把输入框设置成只容许数字输入?我看过每个属性好像都不行的 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 用正则检查一下,bool FoundMatch = false;try { FoundMatch = Regex.IsMatch(SubjectString, "\\d*");} catch (ArgumentException ex) { // Syntax error in the regular expression} 或在keyPress(object sender,KeypressEventArgs)中写switch ((short)e.KeyChar){case 13:case 48:case 49:case 50:case 51:case 52:case 53:case 54:case 55:case 56:case 57:case 08://digits 0-9,backspace and Entere.Handled = false;break;default:e.handled =true;break;}可以在输入的时候就检查 http://msdn2.microsoft.com/en-us/library/system.windows.forms.maskedtextbox.aspx 这样简单try{ Decimal.Parse(str);}catch{ MessageBox.Show("请输入数字。");} .net 2.0中有个MaskTextbox控件,可是在1.0中没有. yuanarea(超级赛亚人)仁兄的解释我看不懂,能不能再说的详细一点啊? 在我的空间里有个这样的控件,ocean.ys168.com,并支持负数和小数.带源码 正则表达式+js鼠标点击事件,搂住google一下n多 限制输入1-9:http://bbs.yespie.com/HDLabShowPost.aspx?ForumID=6&TopicID=210 keypress里面限制ascii的范围,48-57 用TRY判断一下:try{ float ff=float.Parse(textBox1.text);}catch(Exception){ MessageBox.Show("请输入数字");} <script language="javascript"> function CheckNumber() { if(isNaN(Frm.ProductPrice.value)) { alert("价格只能是数字!"); Frm.ProductPrice.value =""; Frm.ProductPrice.focus(); return false; } } </script> 菜鸟求助一个很简单的问题,麻烦说详细一点,谢谢!!! Request["YS_ID"]获得不到GridView 中行主键值? help me.help............ c#Datagrid插入数据(高手请进!) 金额,大小写问题。 请问如何使自定义按钮响应mouseclick的右键点击 菜鸟问题:listview 的用法 请问怎么用C#保存网页 c#基础,c#实例,c#视频教程 Convert.ToDecimal 请教一个关于C#操作EXCEL画曲线图的问题! datagrid显示的问题!!!
bool FoundMatch = false;
try {
FoundMatch = Regex.IsMatch(SubjectString, "\\d*");
} catch (ArgumentException ex) {
// Syntax error in the regular expression
}
switch ((short)e.KeyChar)
{
case 13:case 48:case 49:case 50:case 51:case 52:
case 53:case 54:case 55:case 56:case 57:case 08:
//digits 0-9,backspace and Enter
e.Handled = false;
break;
default:
e.handled =true;
break;
}
可以在输入的时候就检查
try
{
Decimal.Parse(str);
}
catch
{
MessageBox.Show("请输入数字。");
}
搂住google一下n多
try
{
float ff=float.Parse(textBox1.text);
}
catch(Exception)
{
MessageBox.Show("请输入数字");
}
function CheckNumber()
{
if(isNaN(Frm.ProductPrice.value))
{
alert("价格只能是数字!");
Frm.ProductPrice.value ="";
Frm.ProductPrice.focus();
return false;
}
}
</script>