Take the 2-minute tour ×
Code Review Stack Exchange is a question and answer site for peer programmer code reviews. It's 100% free, no registration required.

thanks for visiting , this is my initial question that lead me to modify the behavior of AJAX MaskedEditValidator - isValidEmpty attribute.

when you try to cancel the interaction with a form , being a form that one of its elemets (say the first textbox) is set to "required" . in that case , the validator will not let you do anything unless you first type a valid value in the target text box .

you have no choice other than to fill the field that you set focus to as required.

till then the user is disabled rather than the UI (:.

so I came up with a solution, though I think should be optimized so it would suit any target TextBox (actually target is MaskedEditValidator-ID and the text box is only the referencing entity) in this case .

and also the code is far from being as elegant and clean so i could proudly share it with everyone

  • MaskedEditExtender

      <cc1:MaskedEditExtender enabled="true" MaskType="Date" 
           ID="insertDate_MaskedEditExtender" runat="server"
           TargetControlID="TBXinsertDate"  InputDirection="LeftToRight"
           UserDateFormat="None" Mask="99/99/9999" MessageValidatorTip="true"
           OnFocusCssClass="maskedFocus" ErrorTooltipEnabled="true"
  • MaskedEditValidator

      <cc1:MaskedEditValidator Enabled="false" IsValidEmpty="false"
           ControlToValidate="TBXinsertDate" runat="server"
           InvalidValueBlurredMessage="invalid date" 
           EmptyValueBlurredText="requierd fileld"  
           MaximumValue="01/01/2015" MinimumValue="01/01/2008"
           MinimumValueBlurredText="please enter year above 2008"
           MaximumValueBlurredMessage="max year value is 2015"
  • default state of validator

    Enabled = false : i am enabling it later on via onClick button event from code behind as follows

    insertDate_MskValidator.Enabled = true;

so the sequence is :

stage 1 - validator-enabled = false //when form is hidden

stage 2 - validator-enabled = true //when form is visible

stage 3 options:

cancel / submit

submit: will be available if form is valid

cancel: is no option if you step in one of text box leaving it empty .

and this is my solution :


//delay execution

function setTDisableValidation() {
         setTimeout('disableValidation()', 3500);

//execute modification

    function disableValidation() {
             var myVal = document.getElementById('insertDate_MskValidator');
             myVal.disabled = true;
             myVal.ValidEmpty = true;


<form id="form1" runat="server">
    <asp:ScriptManager ID="ScriptManager1" runat="server">
     <asp:TextBox ID="TBXinsertDate" runat="server" 
          ToolTip="insert date" Width="76px" 


        height: 16px;
        width: 80px;
        padding: 2px 2 2 2px;
        border: 1px solid #BEBEBE;
        background-color: #F0F8FF;
        color: gray;
        font-size: 8pt;
        text-align: center;

        height: 16px;
        width: 168px;
   font-size:10px; color:black; 
              font-size:10px; color:red;display:inline-block;
                      font-size:10px; color:red;display:inline;
        font-size:10px; color:red; background-color:Yellow
share|improve this question

closed as unclear what you're asking by Jamal Nov 25 '13 at 17:24

Please clarify your specific problem or add additional details to highlight exactly what you need. As it's currently written, it’s hard to tell exactly what you're asking. See the How to Ask page for help clarifying this question.If this question can be reworded to fit the rules in the help center, please edit the question.