Sunday 27 January 2013

Telerik RadmaskedTextbox validation experssion that doesn't allow zero at start and not all digits zero in ASP.NET

Regular Expression that doesn't allow any Zero at start and not all digits will be Zero:-


  1. First take a Radmasked textbox and a RegularExpressionValidation control on the aspx page.
  2. Then design it in your requirements.

Here is the Source Code:

------------------------------------------------------------------------------------------------------------
  <telerik:RadMaskedTextBox ID="RadMaskedTextBox1" Runat="server" MaskType="Standard"        Mask="########" CausesValidation="True">
  </telerik:RadMaskedTextBox>

  <asp:RegularExpressionValidator ID="RegularExpressionValidator1" runat="server" 
     ControlToValidate="RadMaskedTextBox1" ErrorMessage="Input is not valid." 
     ValidationExpression="^(?=.*[1-9])(?:[1-9]\d*\.?|0?\.)\d*$">
 </asp:RegularExpressionValidator>


  • The Blue mark code is the regular Expression.