# AJAX MaskedEditValidator isValidEmpty property manipulation [closed]

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

  <cc1:MaskedEditExtender enabled="true" MaskType="Date"
TargetControlID="TBXinsertDate"  InputDirection="LeftToRight"
CultureName="en-GB"
ErrorTooltipCssClass="toolTipForInvalid">



  <cc1:MaskedEditValidator Enabled="false" IsValidEmpty="false"
ID="insertDate_MskValidator"
ControlToValidate="TBXinsertDate" runat="server"
InvalidValueBlurredMessage="invalid date"
EmptyValueBlurredText="requierd fileld"
ErrorMessage="Error"
MaximumValue="01/01/2015" MinimumValue="01/01/2008"
MaximumValueBlurredMessage="max year value is 2015"
CssClass="dateInValid">

• 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 :

## JavaScript

//delay execution

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

//execute modification

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


## ASPX

<body>
<form id="form1" runat="server">
<asp:ScriptManager ID="ScriptManager1" runat="server">
</asp:ScriptManager>
<asp:TextBox ID="TBXinsertDate" runat="server"
ToolTip="insert date" Width="76px"
onblur="setTDisableValidation();">
</asp:TextBox>


## CSS

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

.NormalTextBox
{
height: 16px;
width: 168px;
}
.greytext
{
color:red;
}
{
color:blue;
}
.dateValid
{
font-size:10px; color:black;
}
.dateInValid
{
font-size:10px; color:red;display:inline-block;
}
{
font-size:10px; color:red;display:inline;
}
.toolTipForInvalid
{
font-size:10px; color:red; background-color:Yellow
}

-

## 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.