Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 417
  • Last Modified:

Regular Expression + Disable removal of String + textbox + Asp.net + VB

I have a texbox that is asking a user to enter as asset number.

the first 4 characters are always the same (UGHS)  I want to disable the user from removing these characters.

I then need the user to enter a minimum of 5 digits at the end of UGHS.  I presume this will be done using regular expressions.  
0
skiltz
Asked:
skiltz
  • 5
  • 3
1 Solution
 
McExpCommented:
0
 
skiltzAuthor Commented:
Well I can do UGHS\d+ which works pretty well.  Will have a look at masked edit.
0
 
McExpCommented:
are you doing your regex client side?
0
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 
skiltzAuthor Commented:
Yes
0
 
McExpCommented:
   <asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
    <ajaxToolkit:MaskedEditExtender ID="MaskedEditExtender1" runat="server" TargetControlID="TextBox1" Mask="\U\G\H\S99999">
    </ajaxToolkit:MaskedEditExtender>
0
 
McExpCommented:
Forgot, you need to also set ClearMaskOnLostFocus to false

    <asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
    <ajaxToolkit:MaskedEditExtender ID="MaskedEditExtender1" runat="server" TargetControlID="TextBox1" Mask="\U\G\H\S99999" ClearMaskOnLostFocus="false">
    </ajaxToolkit:MaskedEditExtender>
0
 
skiltzAuthor Commented:
Works great except can't add more than 5 digits..should be minimum of 5 digits..
0
 
McExpCommented:
No Problem, extend the mask (to however digits you need as a max) and use the Validator to check that it is at least 5 digits

    <asp:TextBox ID="TextBox1" runat="server" />

    <ajaxToolkit:MaskedEditExtender ID="MaskedEditExtender1" runat="server"
    TargetControlID="TextBox1" Mask="\U\G\H\S9999999999"  />

    <ajaxToolkit:MaskedEditValidator
    ID="MaskedEditValidator1"
    runat="server"
    ControlExtender="MaskedEditExtender1"
    ControlToValidate="TextBox1" IsValidEmpty="False" ValidationExpression="^UGHS\d{5}....."  
    EmptyValueMessage="Enter at least 5 digits"
    InvalidValueMessage="Enter at least 5 digits"
    />
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

  • 5
  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now