Date value Not updating in Date field | Community
Skip to main content
Level 4
December 20, 2023
Question

Date value Not updating in Date field

  • December 20, 2023
  • 1 reply
  • 1127 views

In Web app I used Jquery to disable the Tuesday and Thursday options in the date picker.
When I select a date in the first click, it does not update, but it does update when I select it again, and the previous date only updates in the date field, not the date I am currently selecting.

FYI:Date field has Date data type

This is the Code Which I tried 
<script src="https://code.jquery.com/jquery-3.6.4.min.js"></script>
<!-- jQuery UI -->
<link rel="stylesheet" href="https://code.jquery.com/ui/1.12.1/themes/base/jquery-ui.css">
<script src="https://code.jquery.com/ui/1.12.1/jquery-ui.js"></script>

$(function() {
var selectedDay; // Declare the variable in a broader scope

$("#datepicker").datepicker({
minDate: 0, // Disable past dates
beforeShowDay: function(date) {
selectedDay = date.getDay(); // Store the day in the broader scope variable

return [selectedDay === 1 || selectedDay === 3 || selectedDay === 5]; // Disable Mondays
},
onSelect: function(dateText, inst) {
// Now you can access the selectedDay variable here
console.log(selectedDay);
}
});
});

here is the date input field
<strong> Date</strong>:</label> <input name="datepicker" id="datepicker" type="text" data-nl-label="Date" data-nl-xpath="@date" data-nl-bindto="xpath" data-nl-type="date" /> <!--<select name="cvv" id="cvv" data-nl-label="Date" data-nl-xpath="@date" data-nl-bindto="xpath">

Thanks in advance






This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.

1 reply

Manoj_Kumar
Community Advisor
Community Advisor
December 21, 2023

Hello @vani97 

 

The code seems to be working fine for me.

But you can force to set the value again by updating the onSelect function like this:

onSelect: function(dateText, inst) { $("#datepicker").val($(this).val()); }
Manoj  | https://themartech.pro
vani97Author
Level 4
December 21, 2023

Hi @_manoj_kumar_ 

FYI The date Field have string Data type 

as we have type as text in the datepicker input field in the html element 

and its getting updated in the google chrome console  what im selecting in datepicker

but in the adobe campaign its updating previous date value

For eg : if im selecting 23/12/2023 its updating empty value 
then if im selecting the 24/12/2023 then its updating 23/12/2023.
 


Manoj_Kumar
Community Advisor
Community Advisor
December 21, 2023

@vani97 

 

How are you saving this information in the field? 

Are you using storage activity or using javascript?

Manoj  | https://themartech.pro