简体   繁体   English

如何在texbox的小数点前后仅允许一个数字?

[英]How to allow only 1 number before and after the decimal point a texbox?

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

Try this 尝试这个

<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 正则表达式演示

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 在 VB.NET 中,如何让文本框只允许一个小数点,&lt; 3NUMBERS 之前,只有 1NUMBER 之后? - In VB.NET how do I get a textbox to only allow one decimal point, < 3NUMBERS before it, and only 1NUMBER after it? Texbox限制字符和符号,并且仅允许数字值带有一个小数点 - Texbox restrict characters and symbols and only allow numeric values with only one decimal point 文本框允许数字为小数点后一位,小数点后一位 - textbox allow a number with one decimal point, and one digit after decimal point Asp.net如何限制textbox按键事件中小数点前后的位数 - Asp.net How to limit number of digits before and after the decimal point in textbox keypress event 如何在 web 表单文本框中只允许数字和一个小数点 - How to allow only digits and one decimal point in a web form textbox 用于检查值的正则表达式必须仅允许小数点后两位数字? - Regular Expression to check a value must allow only two digits after decimal point? 文本框只允许浮点数 - Textbox only allow floating point number 提交后如何清除texbox - How to clear texbox after submission 如何确保仅在第一个小数点后一位上舍入浮点数? - how to make sure the rounding of a floating point number is done only on the first extra decimal position? 如何使用正则表达式验证器仅限制小数点后两位 - how to limit only two digits after decimal point using Regex Validator
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM