web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Pages / Manually Set Value in ...
Power Pages
Answered

Manually Set Value in Date Field

(0) ShareShare
ReportReport
Posted on by 312

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

I am using a script to disable two days after the current date. This is working fine.

 

But it happens that if the user manually enters any date in the field "delivery date" it defeats the whole purpose of the script. That's why I'm looking for a way to remove/disable the "manually enter" option so that the user doesn't enter any date.

 

For example, the date shown was entered manually (06/05/2002). And I want everything that is entered in this field to be through the "Choose Date" button

MartinVargas_0-1652114424846.png

 

Can someone help me here? 

I would appreciate it guys

Categories:
I have the same question (0)
  • natalya Profile Picture
    133 on at

    Hi @MartinVargas ,

    one of the solution would be -adding the validation to the delivery date field - do not accept the current date +2 days. 

    By disabling entry you may have some accessibility issues.

     

    Hoping it helps.

    NatGeo

  • MartinVargas Profile Picture
    312 on at

    Hi @NatGeo Could you tell me an example of how to add a validation, I would greatly appreciate it.  I am new at this.

  • Fubar Profile Picture
    17 Super User 2026 Season 1 on at

    This may not cover all the relevant events (you can add additional ones) but the following will generally stop the user entering in the input field 

    $('#fieldname_datepicker_description').on('keypress paste', function (e) {
     e.preventDefault();
     return false;
    });

     

  • natalya Profile Picture
    133 on at

    Hi @MartinVargas 

     

    You can add functionality provided by PowerApps Portal 

    Add custom JavaScript - Power Apps | Microsoft Docs

    or validate on the user entry, please see the code below:

    $("#kg_dateofbirth").next().on("dp.change", function(e) {
     if ($("#kg_dateofbirth").val()==="Invalid date"){
    	//error message if invalid date
     } 
     else if(!$("#kg_dateofbirth").val()){
    	//error message if empty
    }
     else{
     let controlVal = $("#kg_dateofbirth_datepicker_description").val();
     let today = new moment();
    			today = moment(today).add(2,'d' ).format("YYYY-MM-DDT");
     controlVal = moment(controlVal).format("YYYY-MM-DDT");
     let a= moment(controlVal, "YYYY-MM-DDT", true);
     if(a.isValid() == true){
     if (controlVal > today) {
    			$("#kg_dateofbirth").next().data("DateTimePicker").clear()
    			//error message		
    			} 
     } 
     } 
     });

     Hoping it helps!

    NatGeo

  • Verified answer
    MartinVargas Profile Picture
    312 on at

    Thank you very much @Fubar @NatGeo, both solutions suit what I need.

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Season of Sharing Community Challenge Winners!

Congratulations to our community stars!

Kudos to our 2025 Community Spotlight Honorees

Expanding mentorship, skilling, and AI innovation

Congratulations to the July Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Pages

#1
Fubar Profile Picture

Fubar 33 Super User 2026 Season 1

#2
sannavajjala87 Profile Picture

sannavajjala87 32 Super User 2026 Season 2

#3
Mohsin Ali Profile Picture

Mohsin Ali 25

Last 30 days Overall leaderboard