0
下面的代碼只允許輸入整數,但不是隻輸入整數,我需要給用戶輸入雙倍(0.00)的選項。任何建議或修改?如何在ASPX C#網站的文本框中將值接受爲雙打?
if (_txStaticPressureUpdate.Trim() == "")
{
txSystemMessage.Text = "Field 'Static Pressure' is empty. Please enter a valid value.";
txSystemMessage.ForeColor = System.Drawing.Color.Red;
return;
}
//check that record info entered consists of numbers only/no special characters or letters
for (int j = 0; j < _txStaticPressureUpdate.Length; j++)
{
if (!char.IsControl(_txStaticPressureUpdate[j]))
{
txSystemMessage.Text = "Field 'Static Pressure' has an invalid value.";
txSystemMessage.ForeColor = System.Drawing.Color.Red;
return;
}
else
{
staticPressure = double.Parse(txStaticPressureUpdate.Text.Trim());
}
}
我正在ASPX/C#網站上工作。許多可用的選項都是針對WinForms的。它可以起作用,但在公式的最終結果中更精確,我期待使用雙打。
太棒了!非常感謝你,@James 太棒了!這絕對是完美的! –