Expand my Community achievements bar.

Date value Not updating in Date field

Avatar

Level 4

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






Topics

Topics help categorize Community content and increase your ability to discover relevant content.

4 Replies

Avatar

Community Advisor

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
     Find me on LinkedIn

Avatar

Level 4

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.
 


Avatar

Community Advisor

@vani97 

 

How are you saving this information in the field? 

Are you using storage activity or using javascript?


     Manoj
     Find me on LinkedIn

Avatar

Level 4

I'm using storage activity to store and update the date values in attribute .