Welcome Guest Search | Active Topics | Sign In | Register

Masked Edit validation Options
SDDP
Posted: Tuesday, June 23, 2009 3:16:42 PM
Rank: Member
Groups: Member

Joined: 3/16/2009
Posts: 23
I have a form with a phone number field that I want to use a masked edit control for. The phone number is a required entry. I tried to use the RequiredFieldValidator, but it throws an error because the Maskededit control can't be used with it. So I use the MaskededitValidator control, but it doesn't do anything.
Here is the code:

Code: HTML/ASPX
<eo:MaskedEdit ID="Common_Applicant_PhoneTextBox" runat="server"  Text='<%# Bind("Common_Applicant_Phone") %>'>
        <eo:MaskedEditSegment Text="(" IsRequired="True" />
        <eo:MaskedEditSegment Mask="000) 000-0000" SegmentType="Mask" IsRequired="True" />
    </eo:MaskedEdit>
    <eo:MaskedEditValidator ID="Common_Applicant_PhoneTextBoxValidator" runat="server" 
        ControlToValidate="Common_Applicant_PhoneTextBox" EnableClientScript="False" 
        ErrorMessage="Applicant Phone must not be blank." ValidationGroup="ny">*</eo:MaskedEditValidator>


I know for sure that the validation group is getting called because of other fields on the form. If the user doesn't enter anything, or they enter a partial phone number, I would expect this validator to apply. Am I doing something wrong, or do I not understand what this validator does?
eo_support
Posted: Tuesday, June 23, 2009 8:47:58 PM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 24,070
Hi,

Currently MaskedEditValidator does not support validation group. If you clear its ValidationGroup property, it will function properly. We will look into it and see if we can add support for that.

Thanks!
SDDP
Posted: Tuesday, June 23, 2009 9:01:19 PM
Rank: Member
Groups: Member

Joined: 3/16/2009
Posts: 23
Validation controls should support validation groups. We need to be able to group them on forms.

Also, it seems that the MaskedEdit control doesn't support the RequiredFieldValidator?
It throws an error when I try to use it. The DatePicker seems to support it OK.

If I can't use your validator, and I can't use the RequiredFieldValidator, then I really won't be able to use the MaskedEdit control at all.

thanks
eo_support
Posted: Tuesday, June 23, 2009 9:11:28 PM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 24,070
Hi,

We understand the importance of validation group. So we will look into it and see if we can support that. A simple workaround for this limitation does exist. You can add a standard asp:CustomValidator to your form, then set the CustomValidator's ClientSideValidationFunction to a custom JavaScript validation function (say "ValidatePhoneNumber"):

Code: JavaScript
function ValidatePhoneNumber(sender, args)
{
    var me = eo_GetObject("Common_Applicant_PhoneTextBox");
    args.IsValid = me.isValid();
}


This should resolve the issue (Note you no longer need MaskedEditValidator). I believe the reason that it does not work with RequiredFieldValidator is because RequiredFieldValidator checks whether the text box has a "value" or not, in the case of a MaskedEdit, it has a "value" of "(__) __ ____" even it is an empty phone number.

Thanks!
SDDP
Posted: Wednesday, June 24, 2009 12:51:41 PM
Rank: Member
Groups: Member

Joined: 3/16/2009
Posts: 23
Actually the RequiredFieldValidator fails with this error:

Control 'Common_Applicant_PhoneTextBox' referenced by the ControlToValidate property of 'RequiredFieldValidator6' cannot be validated.

The top method call in the stack trace is:

System.Web.UI.WebControls.BaseValidator.CheckControlValidationProperty(String name, String propertyName) +8734357

But I see what you are saying about the value of the text box not being blank even if the user didn't type in anything.

So I will use the CustomValidator for now, until groups are supported by MaskEditValidator.

Thanks
eo_support
Posted: Wednesday, June 24, 2009 1:10:42 PM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 24,070
Hi,

Thanks for the additional information about the RequiredValidator. We are aware of that. The control needs to be correctly "marked" by certain attributes in order to work with RequiredValidator (or any other validator). We did not mark MaskedEdit control so RequiredValidator won't take it. The reason that we did not mark it is because even if we marked it, it still won't work correctly because of the previously stated reasons.

Thanks!
SDDP
Posted: Wednesday, June 24, 2009 1:34:03 PM
Rank: Member
Groups: Member

Joined: 3/16/2009
Posts: 23
I just ran into that problem, because the ValidationPropertyAttribute isn't set on the control.

I have to validate on the server side, since for this application the user can save incomplete forms and come back later to finish them.

It looks like the server side IsValid isn't doing anything. If I don't enter any phone number, or I enter a partial one, it still shows valid. I am using zeros in the segment, that is supposed to be a required digit?



Code: Visual Basic.NET
Sub Phone_Number_CustomValidator_ServerValidate(ByVal source As Object, ByVal args As ServerValidateEventArgs)

        Dim phonenumber As EO.Web.MaskedEdit = AppFormView.FindControl("Common_Applicant_PhoneTextBox")

        args.IsValid = phonenumber.IsValid

    End Sub
eo_support
Posted: Wednesday, June 24, 2009 2:10:30 PM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 24,070
SDDP wrote:
I just ran into that problem, because the ValidationPropertyAttribute isn't set on the control.

Yes. That is correct. However that's not the only thing needs to be done in order for MaskedEdit to work with RequiredFieldValidator. What we were trying to say is even if set set ValidationPropertyAttribute, it still won't work because the definition of what is "empty" and "not empty" is different than that of a standard textbox and it can be confusing. So we chose not to set it.


SDDP wrote:
It looks like the server side IsValid isn't doing anything. If I don't enter any phone number, or I enter a partial one, it still shows valid. I am using zeros in the segment, that is supposed to be a required digit?

Yes. "0" should be required and the fact that IsValid is not failing blanks appears to be a problem. We will look into it and get back to you as soon as possible.

Thanks!
SDDP
Posted: Wednesday, June 24, 2009 2:39:27 PM
Rank: Member
Groups: Member

Joined: 3/16/2009
Posts: 23
OK thanks. Here is what I am using at this point.

Code: HTML/ASPX
<eo:MaskedEdit ID="Common_Applicant_PhoneTextBox" runat="server"  Text='<%# Bind("Common_Applicant_Phone") %>'>
        <eo:MaskedEditSegment Text="(" IsRequired="True" />
        <eo:MaskedEditSegment Mask="000) 000-0000" SegmentType="Mask" IsRequired="True" />
    </eo:MaskedEdit>
                <asp:CustomValidator ID="CustomValidator1" runat="server" OnServerValidate="Phone_Number_CustomValidator_ServerValidate" ErrorMessage="Applicant Phone must not be blank." Text="*" EnableClientScript="False" ValidationGroup ="ny"></asp:CustomValidator>


With the same VB code above. Still using the 2008 release. If the 2009 release would fix any of this, I will go ahead and change over.

Please let me know what you find out. I promised my client a masked edit for phone numbers and zip codes.
eo_support
Posted: Wednesday, June 24, 2009 2:43:03 PM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 24,070
Hi,

I believe the issue still exists in the current 2009 build. So there is no need to update for now.

BTW: Is there any particular reason that you cannot use the client side validation? That seems to be a workable solution for your case.

Thanks!
SDDP
Posted: Wednesday, June 24, 2009 5:23:11 PM
Rank: Member
Groups: Member

Joined: 3/16/2009
Posts: 23
The reason I can't use client side validation is because in this system, the users can save a form with incomplete entries and then come back later to finish it. So I can't really validate it until they want to submit it, and then it's done server-side.

eo_support
Posted: Friday, June 26, 2009 12:04:13 PM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 24,070
Hi,

We have posted a new build that fixed IsValid issue. Please check your private message for the download location.

Thanks!
SDDP
Posted: Tuesday, June 30, 2009 7:05:11 PM
Rank: Member
Groups: Member

Joined: 3/16/2009
Posts: 23
I downloaded the new build. It appears that you enabled validation groups? I put the maskededit validator control back on my form, and it is working as I expected. It validates that the phone number is filled in completely, and it does this only when the indicated validation group is called.

Thanks.

This code works as you would expect, and no server side code needed.

Code: HTML/ASPX
<eo:MaskedEdit ID="Common_Applicant_PhoneTextBox" runat="server"  Text='<%# Bind("Common_Applicant_Phone") %>' Font-Names="Arial, Helvetica, sans-serif">
                    <eo:MaskedEditSegment Text="(" IsRequired="True" />
                    <eo:MaskedEditSegment Mask="000) 000-0000" SegmentType="Mask" IsRequired="True" />
                </eo:MaskedEdit>
                <eo:MaskedEditValidator ID="MaskedEditValidator1" runat="server" 
                    ControlToValidate="Common_Applicant_PhoneTextBox" EnableClientScript="False" 
                    ErrorMessage="Applicant Phone Number must be filled in." ValidationGroup="ny">*</eo:MaskedEditValidator>
eo_support
Posted: Wednesday, July 1, 2009 2:20:53 PM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 24,070
Yes. I believe both issues are fixed in the new build.


You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.