Last post Nov 18, 2014 05:00 PM by desertfoxaz
Nov 12, 2014 11:24 AM|desertfoxaz|LINK
I have a web form with some fields for Social Security Number and phone number, so I have textboxes set up with MaskedEditExtenders to enforce the proper format during entry. I had used both a RequiredFieldValidator and RegularExpressionValidator to do
this, as well as added ValidationCalloutExtenders to both validators. The problem is that when the submit button is clicked, the fields say they values aren't in the right format -- the RegularExpressionValidator is saying this and the RequiredFieldValidator
doesn't appear to be working.
I realize the mask might be causing the RequiredFieldValidator to think a value is provided, so I changed the InitialValue of match the prompt, but that didn't work. I also tried various combinations of the MaskedEditExtender's properties, namely ClearMaskOnLostFocus
and ClearTextOnInvalid. No matter what I do this doesn't work the way I want to.
I was looking through one of my books and I found the MaskedEditValidator, thinking this might help deal with this issue, so I tried it, but still I can't get the results I'm looking for. If the field with the mask is empty, I need to show a message saying
the field is required. If the entered data doesn't match the format, I want to display a message saying the entered data isn't in the correct format. I've spent a whole day trying to figure this out and I'm stumped. Below is code that does nothing but collect
the SSN. Please tell me what I need to change to get this working. Thanks.
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="MaskedEditTest.Default" %>
<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="act" %>
<form id="form1" runat="server">
<act:ToolkitScriptManager ID="ToolkitScriptManager1" runat="server" EnableViewState="false" />
<asp:Label ID="lblSSN" runat="server" AssociatedControlID="txtSSN" EnableViewState="false" Text="SSN *:" />
<asp:TextBox ID="txtSSN" runat="server" autocomplete="off" AutoCompleteType="Disabled" Columns="11" MaxLength="11" />
<act:MaskedEditExtender ID="meeSSN" runat="server" EnableViewState="false" Mask="999-99-9999" MaskType="Number" TargetControlID="txtSSN" />
<act:MaskedEditValidator ID="mevSSN" runat="server"
EmptyValueMessage="SSN is required"
InvalidValueMessage="SSN must be valid"
<act:ValidatorCalloutExtender ID="vceSSN" runat="server" EnableViewState="false" TargetControlID="mevSSN" />
<asp:Button ID="btnSubmit" runat="server" EnableViewState="false" OnClick="btnSubmit_Click" Text="Submit" />
Nov 13, 2014 09:26 PM|Kevin Shen - MSFT|LINK
For your issue ,I have tested it your code in my side.
It seems that ValidatorCalloutExtender doesn't support well with MaskedEditExtender . I suggest that you can try some other way to replace ValidatorCalloutExtender
Here is similar issue like yours:
Nov 14, 2014 10:07 AM|desertfoxaz|LINK
So this was identified four years ago...I am not using the latest release but the newer ones are very buggy. Looks like the last release was December 2013. I had read earlier that DevExpress is taking it over from SuperExpert which has negelected it. No
new releases until sometime in 2015 unfortunately. I am sure by then I'll be using MVC so this will be a moot point.
So for now I guess I'll just stop using masked edit extenders or validator callout extenders. Which sucks, but what can I do?
Nov 18, 2014 06:02 AM|Kevin Shen - MSFT|LINK
I have tried it in the latest release ajax control toolkit, the ValidatorCalloutExtender doesn't support well with MaskedEditExtender .
I suggest that you can use jquery validate plugin to replace the ValidatorCallout Extender.
Nov 18, 2014 05:00 PM|desertfoxaz|LINK
I'll look into it. We don't use jQuery very often around here but we'd need to integrate it with the server-side validation.
Our site design is using Bootstrap and I've noticed it's messing up the appearance of the ValidatorCalloutExtenders. I'm probably going to have to stop using those unless I can find a workaround.