In CRM portal the onchange event is will be working usual jQuery method for text field but when it comes to date fields we cant call the onchange event using the Date field id rather we can call this using Div Control.
I got a requirement that when user select future date, should alert that "future date is not allowed".
for example if user select the future date for "Date Of Birth" field it should alert the user to select past date.
Step 1:
Step 2: Open Developer tool (Press F12) and select console tab
Step 3: Type $('div.control')
Step 4: Inspect the field and get the div control index.
Step 5: In this example my field is in index 8.
Step 6: Copy the below code and paste in your custom js placeholder using inline editing tool for your page.
Sample Code:
var dp123 = $('div.control')[8];
$(dp123).on("dp.change",function(e){
alert("The onchange event of datepicker is fired");
var today = new Date();
if(e.date > today)
{
alert("Future Date is not allowed");
}
});
I got a requirement that when user select future date, should alert that "future date is not allowed".
for example if user select the future date for "Date Of Birth" field it should alert the user to select past date.
Step 1:
Step 2: Open Developer tool (Press F12) and select console tab
Step 3: Type $('div.control')
Step 4: Inspect the field and get the div control index.
Step 5: In this example my field is in index 8.
Step 6: Copy the below code and paste in your custom js placeholder using inline editing tool for your page.
Sample Code:
var dp123 = $('div.control')[8];
$(dp123).on("dp.change",function(e){
alert("The onchange event of datepicker is fired");
var today = new Date();
if(e.date > today)
{
alert("Future Date is not allowed");
}
});