cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
MartinVargas
Post Patron
Post Patron

Disable weekends in date field

Hello community, I am working with a portal in power apps.

Using the following script, I am trying to disable weekends in the "Boarding Date" field, but it does not work. This is the script I am implementing:

 

 

$(document).ready(function(){
$('#crb57_boardingdate').datetimepicker({daysOfWeekDisabled: [0,6]});
});

 

 

MartinVargas_0-1656517659157.png

 

 

Can someone help me here?

I would appreciate it guys

1 ACCEPTED SOLUTION

Accepted Solutions
MartinVargas
Post Patron
Post Patron

Hi, @OliverRodrigues @renatoromao . Sure, I actually found a very simple solution:

 

$(document).ready(function() {
 
    //Disable boarding date, days: Saturdays and Sundays.
    $('#crd4f_fechaentrega').next().data("DateTimePicker").daysOfWeekDisabled([0,6]);

});
 

 

Thanks.

View solution in original post

3 REPLIES 3
renatoromao
Super User
Super User

Hi  @MartinVargas , 

Your page may be is loading before your component with your "$(document).ready". 

You can try two ways:

 

1- Set a delay (2 secs):$(document).ready(function(){ setTimeout(function(){ $('#crb57_boardingdate').datetimepicker({daysOfWeekDisabled: [0,6]}); }, 2000); }); 

2- Change the format allowing English validation (may your date is not starting with Monday)

 

Disable Weekend (Saturday and Sunday) in Bootstrap Datepicker (aspsnippets.com)

.datepicker({
                startDate: new Date(),
                format: "dd/mm/yyyy",
                daysOfWeekHighlighted: "0,6",
                language: 'en',
                daysOfWeekDisabled: [0, 6]
            });

 


 

@MartinVargas


Did I answer your question? Mark my post as a solution!
Thanks!

Renato Romão,

Connect with me here 😉

Power Virtual Agents course (+2.760 students) : English | Português
OliverRodrigues
Super User
Super User

@MartinVargas did Renato's solution work for you? please let us know if you need any further help




If you like this post, give a Thumbs up. Where it solved your request, Mark it as a Solution to enable other users find it.

Power Pages Super User | MVP


Oliver Rodrigues


 

MartinVargas
Post Patron
Post Patron

Hi, @OliverRodrigues @renatoromao . Sure, I actually found a very simple solution:

 

$(document).ready(function() {
 
    //Disable boarding date, days: Saturdays and Sundays.
    $('#crd4f_fechaentrega').next().data("DateTimePicker").daysOfWeekDisabled([0,6]);

});
 

 

Thanks.

Helpful resources

Announcements
Microsoft 365 Conference – December 6-8, 2022

Microsoft 365 Conference – December 6-8, 2022

Join us in Las Vegas to experience community, incredible learning opportunities, and connections that will help grow skills, know-how, and more.

Difinity Conference 2022

Difinity Conference 2022

Register today for two amazing days of learning, featuring intensive learning sessions across multiple tracks, led by engaging and dynamic experts.

European SharePoint Conference

European SharePoint Conference

The European SharePoint Conference returns live and in-person November 28-December 1 with 4 Microsoft Keynotes, 9 Tutorials, and 120 Sessions.

Users online (2,780)