J
John Walker
Hi,
There is a textbox in my datagrid where the user can enter a date manually
or they can use a popup calendar which will automatically fill in the textbox
when they click on a date. This textbox has a compare validator on it, which
is shown below.
When the user types in a date, the validators fire correctly, but when the
pop-up calendar is used, the validators are not fired. They should be fired
when the user clicks on the submit button, which executes "ConfirmUpdate"
which I included at the bottom.
Do you have any idea why the validators work one way but not the other?
Thanks!
John
Here's my validator:
<asp:CompareValidator
ControlToValidate="txtTrkPUDate"
display =dynamic
Text="Date is too far past!"
Operator=GreaterThanEqual
Type="Date"
Runat="Server" ID="cvPickupXDaysPast"/>
Here's where I set the ValueToCompare in ItemDataBound:
cv = CType(e.Item.FindControl("cvPickupXDaysPast"), CompareValidator)
cv.ValueToCompare = DateTime.Today.AddDays(-7).ToShortDateString()
Here's a portion of the popup calendar window that fills the textbox with a
date:
window.opener.document.all['" &
Httpcontext.Current.Request.Querystring("controlname") & "'].value =
'1/1/2000';
Here's the javascript on the submit button which is supposed to check the
validators:
function ConfirmUpdate() {
if (Boolean(Page_IsValid) == 0)
{
alert('Invalid value.');
return false;
}
return true;
}
There is a textbox in my datagrid where the user can enter a date manually
or they can use a popup calendar which will automatically fill in the textbox
when they click on a date. This textbox has a compare validator on it, which
is shown below.
When the user types in a date, the validators fire correctly, but when the
pop-up calendar is used, the validators are not fired. They should be fired
when the user clicks on the submit button, which executes "ConfirmUpdate"
which I included at the bottom.
Do you have any idea why the validators work one way but not the other?
Thanks!
John
Here's my validator:
<asp:CompareValidator
ControlToValidate="txtTrkPUDate"
display =dynamic
Text="Date is too far past!"
Operator=GreaterThanEqual
Type="Date"
Runat="Server" ID="cvPickupXDaysPast"/>
Here's where I set the ValueToCompare in ItemDataBound:
cv = CType(e.Item.FindControl("cvPickupXDaysPast"), CompareValidator)
cv.ValueToCompare = DateTime.Today.AddDays(-7).ToShortDateString()
Here's a portion of the popup calendar window that fills the textbox with a
date:
window.opener.document.all['" &
Httpcontext.Current.Request.Querystring("controlname") & "'].value =
'1/1/2000';
Here's the javascript on the submit button which is supposed to check the
validators:
function ConfirmUpdate() {
if (Boolean(Page_IsValid) == 0)
{
alert('Invalid value.');
return false;
}
return true;
}