Hi @Simflex,
I'm assuming your PurchaseDate and RefundAmount are fetched from the database, then the date is selected via the ReturnDate date picker by disabling the textbox based on the condition.
Specifically, you can view the following code:
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
<script src="https://code.jquery.com/jquery-3.6.3.min.js"></script>
<script src="https://code.jquery.com/ui/1.13.2/jquery-ui.min.js"></script>
<link href="https://code.jquery.com/ui/1.13.2/themes/base/jquery-ui.css" rel="stylesheet" />
<script type="text/javascript">
$(function () {
$('[id*=PurchaseDate]').datepicker({ minDate: 0 });
$('#ReturnDate').datepicker({
minDate: 0,
onSelect: function () {
var returnDate = $('#ReturnDate').val();
var rpPurchaseDateArray = document.getElementsByClassName('rpPurchaseDate');
var rpRefundAmount = document.getElementsByClassName('rpRefundAmount');
for (var i = 0; i < rpPurchaseDateArray.length; i++) {
var purchaseDate = rpPurchaseDateArray[i].value;
if (Date.parse(returnDate) - Date.parse(purchaseDate) > 60 * 86400 * 1000) {
rpRefundAmount[i].disabled = true;
}
else {
rpRefundAmount[i].disabled = false;
}
}
}
});
});
</script>
</head>
<body>
<form id="form1" runat="server" style="margin-left: 200px;" autocomplete="off">
<div>
<table>
<tr>
<td>
<asp:TextBox ID="ReturnDate" runat="server" />
</td>
</tr>
</table>
</div>
<div>
<asp:Repeater ID="DynamicRepeater" runat="server">
<HeaderTemplate>
<table border="1">
<tr>
<td><b>Refund Amount</b></td>
<td><b>Purchase Date</b></td>
</tr>
</HeaderTemplate>
<ItemTemplate>
<tr>
<td>
<asp:TextBox ID="RefundAmount" CssClass="rpRefundAmount" runat="server" Text='<%# Eval("RefundAmount")%>'></asp:TextBox>
</td>
<td>
<asp:TextBox ID="PurchaseDate" CssClass="rpPurchaseDate" runat="server" Text='<%# Eval("PurchaseDate", "{0: MM/dd/yyyy}")%>' />
</td>
</tr>
</ItemTemplate>
<FooterTemplate>
</table>
</FooterTemplate>
</asp:Repeater>
</div>
</form>
</body>
</html>
Best regards,
Lan Huang
If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.