Home > Mobile >  Javascript DateTimePicker without the date
Javascript DateTimePicker without the date

Time:11-18

I have spent far too long trying to find a solution for this problem and have decided I'm asking for help.

I'm looking for some sort of datetime picker to use in my web app that will store and adjust the date based on the time, but will not allow the user to actually adjust the date. So if it initializes to 10/25/21 9:00 AM and the user adjusts the time backwards to 12:00 AM, then further back to 11:59 PM the previous day, it will adjust the date to be 10/24/21 accordingly. But the user isn't able to actually adjust the date themselves like a proper date picker.

Project is using MVC Razor so the date from the model used to initialize is just a C# datetime, and that's also what the data needs to serialize too when submitting.

Any recommendations? Please help.

CodePudding user response:

You can render this field as hidden and attach picker to button. I have done it with https://www.daterangepicker.com/#examples and it works quite well. Some kind of validation is required. Then you can update hidden field, that will be passed together with model to the controller.

  • Related