Answered by:
CompareValidator - Strange behavior

Question
-
User1700504264 posted
Hello
I am using the CompareValidator to ensure that the end date is not earlier than the start date.
it compares two textboxes each of which extended using the (AJAX calendar).
it works <g class="gr_ gr_350 gr-alert gr_gramm gr_inline_cards gr_run_anim Style multiReplace" id="350" data-gr-id="350">fine ,</g> but in some <g class="gr_ gr_401 gr-alert gr_gramm gr_inline_cards gr_run_anim Punctuation only-ins replaceWithoutSep" id="401" data-gr-id="401">cases</g> it <g class="gr_ gr_392 gr-alert gr_gramm gr_inline_cards gr_run_anim Grammar multiReplace" id="392" data-gr-id="392">do</g> not work as expected
for example
value in txtActiviityEnd (12/31/2018)
value in txtActivityStart (01/01/2018)
the validator should not be activated in this <g class="gr_ gr_527 gr-alert gr_gramm gr_inline_cards gr_run_anim Style multiReplace" id="527" data-gr-id="527">case ,</g> since it is an acceptable case, but at <g class="gr_ gr_577 gr-alert gr_spell gr_inline_cards gr_run_anim ContextualSpelling ins-del" id="577" data-gr-id="577">run time</g> it is activated and show the error <g class="gr_ gr_634 gr-alert gr_gramm gr_inline_cards gr_run_anim Style multiReplace" id="634" data-gr-id="634">message !</g>
any help <g class="gr_ gr_646 gr-alert gr_gramm gr_inline_cards gr_run_anim Punctuation only-ins replaceWithoutSep" id="646" data-gr-id="646">please</g>?
<asp:CompareValidator ControlToValidate="txtActivityEnd" ControlToCompare="txtActivityStart" Operator="GreaterThanEqual" ValidationGroup="SaveActivity" ErrorMessage='<% $ Resources:wrongdateinterval %>' Display="Dynamic" CssClass="text-danger" runat="server"> </asp:CompareValidator>
Friday, October 26, 2018 9:21 PM
Answers
-
User475983607 posted
Try setting the Type attribute to date. Plus you have an extra ">" syntax error.
<asp:CompareValidator ControlToValidate="txtActivityEnd" ControlToCompare="txtActivityStart" Operator="GreaterThanEqual" ValidationGroup="SaveActivity" ErrorMessage='<% $ Resources:wrongdateinterval %>' Display="Dynamic" CssClass="text-danger" runat="server" Type=Date </asp:CompareValidator>
- Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
Friday, October 26, 2018 10:32 PM
All replies
-
User475983607 posted
Try setting the Type attribute to date. Plus you have an extra ">" syntax error.
<asp:CompareValidator ControlToValidate="txtActivityEnd" ControlToCompare="txtActivityStart" Operator="GreaterThanEqual" ValidationGroup="SaveActivity" ErrorMessage='<% $ Resources:wrongdateinterval %>' Display="Dynamic" CssClass="text-danger" runat="server" Type=Date </asp:CompareValidator>
- Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
Friday, October 26, 2018 10:32 PM -
User1700504264 posted
Try setting the Type attribute to date. Plus you have an extra ">" syntax error.
<asp:CompareValidator ControlToValidate="txtActivityEnd" ControlToCompare="txtActivityStart" Operator="GreaterThanEqual" ValidationGroup="SaveActivity" ErrorMessage='<% $ Resources:wrongdateinterval %>' Display="Dynamic" CssClass="text-danger" runat="server" Type=Date </asp:CompareValidator>
Thank <g class="gr_ gr_38 gr-alert gr_gramm gr_inline_cards gr_run_anim Style multiReplace" id="38" data-gr-id="38">you ,</g> yes the date attribute solved the problem
Saturday, October 27, 2018 5:37 AM