This is a migrated thread and some comments may be shown as answers.

Formatting an SSN so user only has to enter the numbers

1 Answer 455 Views
Input
This is a migrated thread and some comments may be shown as answers.
MArkB
Top achievements
Rank 1
MArkB asked on 25 Apr 2013, 06:56 PM
HI folks,

I've got myself a RadTextBox where the users are creating new records where one of the values is an SSN. From one of the examples I got the validation to make sure it's in the right format and that's working as expected. I'd like to add to the behavior so that it doesn't require the user to enter the dashes. In a best case scenario, the user could enter the dashes, or not, and the system will still accept the value.

This is whut I've got now:
<telerik:RadTextBox ID="txtSSN" runat="server" EmptyMessage="Enter valid SSN..." Width="250px"></telerik:RadTextBox>
          <asp:RequiredFieldValidator ID="RequiredFieldValidator4" runat="server" ValidationGroup="AddPatient" ErrorMessage="* Required Field" ControlToValidate="txtSSN" /><br />    
          <asp:RegularExpressionValidator id="ssnValidator" runat="server" Display="Dynamic" ErrorMessage="Invalid SSN format"
          ValidationExpression="\d{3}-\d{2}-\d{4}" ControlToValidate="txtSSN">

Thanks for the help.

MArk B.

1 Answer, 1 is accepted

Sort by
0
Vasil
Telerik team
answered on 30 Apr 2013, 08:46 AM
Hello Mark,

We don't have control, that to provide you masked with optional symbols. The closes to your requirements is RadMaskedTextBox that will autotype the Hyphen-minus automatically. Here is an example:

<telerik:RadMaskedTextBox ID="txtSSN" runat="server" Mask="###-##-####"></telerik:RadMaskedTextBox>
<asp:RequiredFieldValidator ID="RequiredFieldValidator4" runat="server" Text="* Required Field" ControlToValidate="txtSSN" /><br />
<asp:RegularExpressionValidator ID="ssnValidator" runat="server" Text="Invalid SSN format"
    ValidationExpression="\d{3}-\d{2}-\d{4}" ControlToValidate="txtSSN">
</asp:RegularExpressionValidator>


Greetings,
Vasil
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
Tags
Input
Asked by
MArkB
Top achievements
Rank 1
Answers by
Vasil
Telerik team
Share this question
or