Hello,
I have a marketing form for a callback service in which the user can choose with a date field when he would like to be called.
Unfortunately, the fields for Sundays are also available, but shouldn't be here in this case.
Can someone please tell me how I can hide or gray out Sundays here?
Many thanks.
Best regards,
Ferdinand Ganter
Hi Clofly,
My Script is already in Marketing page.
I think I should debug it well.
Thank you for the help & quick response. :)
Regards,
Vivek
Hi Vivek,
Script inside source code of marketing form will always be ignored, it is by design.
Please put your code to marketing page instead.
Regards,
Clofly
Yes field ID is correct. I can also confirm it from pre-suggestions I get while entering field values.
It works for me when my script is like this & my field is outside the form(that is created in Marketing Page):
<script>
$( function() {
$( "#ba834639-e227-eb11-a813-0022480a006f" ).datepicker({
beforeShowDay: function (date) {
var day = date.getDay();
return [(day != 0), ''];
}
});
});
</script>
but it does not work when my script is like below for a field inside the marketing form:
<script>
MsCrmMkt.MsCrmFormLoader.on('afterFormRender', function (event) {
$("#ba834639-e227-eb11-a813-0022480a006f").datepicker({
beforeShowDay: function (date) {
var day = date.getDay();
return [(day != 0), ''];
}
});
})
</script>
And my field on a form is :
<div class="lp-form-field" data-required-field="false"><label for="ba834639-e227-eb11-a813-0022480a006f" class="lp-ellipsis" title="">Date String</label><input id="ba834639-e227-eb11-a813-0022480a006f" name="ba834639-e227-eb11-a813-0022480a006f" type="text" placeholder="" class="lp-form-fieldInput" title="" style="width: 100%; box-sizing: border-box;"></div>
Thank you
Hi Vivek,
Check whether id of the input field you want to capture is right.
Regards,
Clofly
Hi Clofly,
For me I am unable to inject a datepicker for a field in a form.
It is only working for fields outside the form. Have you implemented this before?
Please help
Thank you
Hi Clofly,
thank you for your quick and detailed answer. That helped me alot.
Thank you.
Regards,
Ferdinand
Hi Ferdinand,
Could the solution work for you?
Regards,
Clofly
Hi Ferdinand,
Unfortunately, the date picker is built-in widget of browser, the only customization we can add to is setting its earliest and latest date to accept.
(It is "date" type input element.)
https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input/date
Therefore, the only option for us is to inject a custom date picker to the date field.
However, due to Dynamics will always set date type field to date type input element, we have to create a single line text field to support custom date picker,
then triggering a plugin/flow on update of Contact and on change of the text field to sync string date to real date field.
Here are steps:
1. Add required libraries to source code of marketing page.(In its head tag.)
* jquery.min.js
* jquery-ui.js
* jquery-ui.css
2. After form render, inject date picker of jQueryUI to the custom single line text field.
(We can get its id in HTML editor of marketing form, or with browser inspector.)
Because date picker of jQueryUI is supported to disable specific dates.
3. Now in marketing form, Sunday has been disabled in calendar.
Regards,
Clofly
Stay up to date on forum activity by subscribing. You can also customize your in-app and email Notification settings across all subscriptions.
André Arnaud de Cal... 291,240 Super User 2024 Season 2
Martin Dráb 230,149 Most Valuable Professional
nmaenpaa 101,156