protected bool Validate()
{
bool _CanGoOn = true;
//验证数据的完整性和合法性
if(this.TxTTexture.Text == ""){
error += " 物料材质一定要填写";
_CanGoOn = false;
}
if(this.TxTPlanPrice.Text != ""){
try{
if(double.Parse(this.TxTPlanPrice.Text) < 0)
{
Alert("计划价格必须大于0!");
_CanGoOn = false;
}
}
catch{
Alert("计划价格必须为数字!");
_CanGoOn = false;
}
}
return _CanGoOn;
}
本文介绍了一种表单验证的方法,确保用户输入的数据既完整又合法。重点讲解了如何检查必填字段及验证数值型数据的有效性,包括对负数和非数字字符的处理。
493

被折叠的 条评论
为什么被折叠?



