html5 date imput – disable date manual input

thcom
Backer | 94
+
0
-

hi i have this date field in my form

        $tomorrow = DateTime::from(0)->modifyClone('+1 Day')->format('Y-m-d');
        $rezervaceForm->addText('datum', 'datum')
	    ->setType('date')
            ->setHtmlAttribute('min', $tomorrow)
            ->setRequired();

how can i disable to manual input the date to the edit
i need enabled only pick from calendar

thank you

https://th1024.cz/images/dp.png

Polki
Member | 553
+
0
-

use JS/jQuery etc.

dakur
Member | 493
+
+1
-

@thcom It's not possible. There is a hack, but when user has browser which doesn't support input[type=date], the input stops working at all for such user.

But I'm wondering – why would you need to disable it? If you have reservation system, you should check on backend that valid date was given, disabling manual mode is not enough.

From the user point of view – when I make reservation, I always click the calendar to see what dates are available. If I make a blind-shot and type date there, it's my problem that server returns an error after submitting the form. But I guess that would be quite rare use-case.

Last edited by dakur (2021-09-14 10:10)