Saturday, 7 September 2013

how to use ajax masked edit control extender for alphanumeric

how to use ajax masked edit control extender for alphanumeric validations

   ****Masked Edit Extender allows user to Input (Specific) formatted Data.

1) Create Website
2) Add aspx page
3) Add toolkitScriptManager
4) If you don't have ajax control toolkit  download from codeplex
5) Add Masked Edit Control Extender

asp:MaskedEditExtender  Properties
 1)TargetControlID  Textbox control where you enter the formatted data
2) MaskType --> for alphanumeric NONE
                          for Number Number
                          for Time Time
                          for Date Date
                         for DateTime DateTime
                           This is required for validating Alpha Numeric Data

In this example how to Validate Alphanumeric values using Masked Edit Control

   Format of the AlphaNumeric is AAAAA9999A(5alphabets followed by 4 digits then one letter) 

      <b> Enter PAN CARD:</b><asp:TextBox ID="txtPan" runat="server"></asp:TextBox>

      <asp:MaskedEditExtender ID="MaskedEdit1" runat="server"
       MaskType="None" Mask="LLLLL9999L" ClearMaskOnLostFocus="true"
        ErrorTooltipEnabled="true" MessageValidatorTip="true" 

        <asp:MaskedEditValidator ID="MEV1" runat="server"
         ControlExtender="MaskedEdit1" ControlToValidate="txtPan"
         ErrorMessage="Format should be AAAAA9999A"
         EmptyValueMessage="This field should not be empty"
         InvalidValueMessage="Format should be AAAAA9999A"
         Display="Dynamic" ValidationExpression="[A-Za-z]{5}\d{4}[A-Za-z]"

         <br />
<asp:Button ID="btnSubmit" runat="server" Text="Validate" OnClick="btnSubmit_Click" />

Here is the OUTPUT