Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8438743
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T07:47:57+00:00 2026-06-10T07:47:57+00:00

I am having trouble with the asp.net MaskedEditExtender and MaskedEditValidator. I have created a

  • 0

I am having trouble with the asp.net MaskedEditExtender and MaskedEditValidator. I have created a custom control with a phone mask and a masked validator. There are two issues that I am having that I could use some help to fix.

Issue 1 – I have a ValidationExpression that validates a phone number, but if I set the EnableClientScript = false it will not display the message on the screen. It will validate it correctly and not let them pass, but the message does not display. If it is true it will display, however I only want to do server side validation.

Issue 2 – Sometimes my control is not required. Is there a way to have the validation expression only trigger if the mask is not empty? Right now if it is required the EmptyValueMessage is displayed and the validation is triggered if text is entered. However, if the IsValidEmpty is true the validation expression triggers when it is empty and thus does not allow empties. Is there a way to only trigger it if not empty or do I have to update the expression to allow the empty mask? If I have to update the expression, does anyone have a good example? (sorry, regex is a weakness of mine)

Below is my code.

_maskedEditExtender.ID = "maskedExt" + this.ID;
_maskedEditExtender.ClientIDMode = System.Web.UI.ClientIDMode.Static;
_maskedEditExtender.TargetControlID = this.ID;
_maskedEditExtender.MaskType = MaskedEditType.None;
_maskedEditExtender.Mask = "(999) 999-9999";
_maskedEditExtender.InputDirection = MaskedEditInputDirection.LeftToRight;
_maskedEditExtender.ClearMaskOnLostFocus = false;

_maskedEditValidator.ID = "maskedVal" + this.ID;
_maskedEditValidator.ControlToValidate = this.ID;
_maskedEditValidator.ControlExtender = _maskedEditExtender.ID;
_maskedEditValidator.InitialValue = "(___) ___-____";
_maskedEditValidator.IsValidEmpty = !Required;
_maskedEditValidator.ValidationExpression = @"^[01]?[- .]?(\([2-9]\d{2}\)|[2-9]\d{2})[- .]?\d{3}[- .]?\d{4}$";
_maskedEditValidator.EmptyValueMessage = "Please enter a phone number.";
_maskedEditValidator.InvalidValueMessage = "Please enter a valid phone number.";

_maskedEditValidator.ValidationGroup = "FormsValidationGroup";
_maskedEditValidator.CssClass = "FormValidation";
_maskedEditValidator.EnableClientScript = false;
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-10T07:47:59+00:00Added an answer on June 10, 2026 at 7:47 am

    Issue 1… I never got a response on how to correct this, and the users preferred it to post back everytime so I just set enableclientscript = false.

    Issue 2… maskedEditValidator.ValidationExpression = @”^[01]?[- .]?(([2-9]\d{2})|[2-9]\d{2})[- .]?\d{3}[- .]?\d{4}|(() __-_)$”;

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am having trouble adding ajax functionality to existing asp.net 4 website. I have
I am having trouble displaying results recieved from asp.net WebMethod. I have a HTML
I'm having some trouble with the ASP.NET 2.0 Login Control. I've setup a database
I'm having trouble with my ASP.NET MVC 3 application. I have 2 propertiesin my
I am having trouble using JQuery with ASP.net. I have a HTML img ,
I have an ASP.NET website and am having trouble capturing some specific requests that
I'm having trouble implementing a functionality on my c#/asp.net app. I have a form
I am having trouble getting ASP.Net MVC 4 running on IIS 6. First, i
I am having some trouble with a asp.net MVC3 web application that I am
I am trying to scrape an ASP.NET website but am having trouble getting the

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.