如何在小数点前后只允许一个数字一个文本框?

时间:2014-02-10 10:20:42

标签: asp.net

<asp:RegularExpressionValidator
    ID="RegularExpressionValidator1"
    CssClass="error"
    SetFocusOnError="true"   
    runat="server"
    ErrorMessage="Error.."
    Display="Dynamic"
    ControlToValidate="txttextbox"    
    ValidationExpression="^[0-9]+\.[0-9]{1}$"
    ValidationGroup="insert">

1 个答案:

答案 0 :(得分:0)

试试这个

<asp:RegularExpressionValidator
    ID="RegularExpressionValidator1"
    CssClass="error"
    SetFocusOnError="true"   
    runat="server"
    ErrorMessage="Error.."
    Display="Dynamic"
    ControlToValidate="txttextbox"
    ValidationExpression="^\d{1}(\.\d{0,1})?$"    
    ValidationGroup="insert">

Regex Demo