Hi @Aypn CNN ,
I tested your code. Your RequiredFieldValidato control is not in effect. You need to disable client-side validation so that the validation controls always perform validation on the server,The documentation states:
If client-side validation is not active (because the browser does not support it or because it has been disabled by using the Page.ClientTarget page directive or EnableClientScript property)
A lot of your verification information is repeated, I wrote a simple example based on your code:
<div class="input-group date">
<div class="input-group-addon">
<i class="fa fa-calendar"></i>
</div>
<asp:TextBox ID="txt_TransactionDate" runat="server" CssClass="form-control" placeholder="Future Date NotAllow" Width="200px" autocomplete="off" ></asp:TextBox>
<asp:RequiredFieldValidator ID="RFV_TxnDate" Display="Dynamic" runat="server" EnableClientScript="false" ErrorMessage="Transaction Date shoud not null!" ForeColor="red" ControlToValidate="txt_TransactionDate" ValidationGroup="group3"></asp:RequiredFieldValidator>
</div>
<div class="form-group">
<label>01.Bank Proof Type *</label>
<asp:DropDownList ID="ddlBankDocType" runat="server" CssClass="form-control" Width="170px">
<asp:ListItem Text="--Select--" Value="0"></asp:ListItem>
<asp:ListItem Text="Bank Statement" Value="1"></asp:ListItem>
<asp:ListItem Text="Bank Passbook" Value="2"></asp:ListItem>
<asp:ListItem Text="Cancelled Cheque" Value="3"></asp:ListItem>
</asp:DropDownList>
<asp:RequiredFieldValidator ID="Rfv_DDLBankDoc" runat="server" ErrorMessage="Please Select a Bank uploading Document Type!" EnableClientScript="false" ForeColor="red" InitialValue="0" ControlToValidate="ddlBankDocType" ValidationGroup="group3" Display="Dynamic"></asp:RequiredFieldValidator>
</div>
<asp:Button ID="Button1" runat="server" Text="Button" ValidationGroup="group3" OnClientCl ick="dtChange()"/>
EDIT
fun ction pa geLo ad ( ) {
$('#txt_TransactionDate').datepicker({
Format: 'dd/mm/yyyy',
autoclose: true,
maxDate: '+90d',
onClose: function (date, datepicker) {
var DocTypeId = $("#ddlBankDocType").val();
if (date != "" && DocTypeId != 0) {
var today = new Date();
var txndt = $("#txt_TransactionDate").datepicker("getDate");
var diff = new Date(txndt - today);
var days = diff / 1000 / 60 / 60 / 24;
if (Math.round(days) > 90 && DocTypeId == 1) {
alert("Sorry, In comparison to today, The Last Banking Statement Transaction Date should be within 90 days!");
}
if (Math.round(days) > 90 && DocTypeId == 2) {
alert("Sorry, In comparison to today, The Last Passbook Transaction Date should be within 90 days!");
}
}
else if (date == "") {
alert("Transaction Date shoud not null!");
}
else if (DocTypeId == 0) {
alert(" Please Select a Bank uploading Document Type!");
}
}
});
}
wi n dow.onlo ad = pa geLo ad;
<div class="input-group date">
<div class="input-group-addon">
<i class="fa fa-calendar"></i>
</div>
<asp:TextBox ID="txt_TransactionDate" runat="server" CssClass="form-control" placeholder="Future Date NotAllow" Width="200px" autocomplete="off" ></asp:TextBox>
</div>
<div class="form-group">
<label>01.Bank Proof Type *</label>
<asp:DropDownList ID="ddlBankDocType" runat="server" CssClass="form-control" Width="170px">
<asp:ListItem Text="--Select--" Value="0"></asp:ListItem>
<asp:ListItem Text="Bank Statement" Value="1"></asp:ListItem>
<asp:ListItem Text="Bank Passbook" Value="2"></asp:ListItem>
<asp:ListItem Text="Cancelled Cheque" Value="3"></asp:ListItem>
</asp:DropDownList>
</div>
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.