From 1831013d4d809fbac92fd3e778b9d35a7d3b8be5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kate=C5=99ina=20=C4=8C?= Date: Tue, 1 Dec 2020 20:39:24 +0100 Subject: [PATCH] =?UTF-8?q?input=20type=20dat=20a=20telefon=C5=AF=20ve=20f?= =?UTF-8?q?ormul=C3=A1=C5=99=C3=ADch?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- seminar/forms.py | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/seminar/forms.py b/seminar/forms.py index be722e16..e45c50f6 100644 --- a/seminar/forms.py +++ b/seminar/forms.py @@ -10,6 +10,13 @@ import seminar.models as m from datetime import date import logging +class DateInput(forms.DateInput): + input_type = 'date' + +class TelInput(forms.TextInput): + input_type = 'tel' + input_pattern="^[+]?[()/0-9. -]{9,}$" + class LoginForm(forms.Form): username = forms.CharField(label='Přihlašovací jméno', max_length=256, @@ -42,8 +49,8 @@ class PrihlaskaForm(forms.Form): pohlavi_muz = forms.ChoiceField(label='Pohlaví', choices = ((True,'muž'),(False,'žena')), required=True) email = forms.EmailField(label='E-mail',max_length=256, required=True) - telefon = forms.CharField(label='Telefon',max_length=256, required=False) - datum_narozeni = forms.DateField(label='Datum narození', required=False) + telefon = forms.CharField(widget=TelInput(),label='Telefon',max_length=256, required=False) + datum_narozeni = forms.DateField(widget=DateInput(),label='Datum narození', required=False) ulice = forms.CharField(label='Ulice', max_length=256, required=False) mesto = forms.CharField(label='Město', max_length=256, required=False) psc = forms.CharField(label='PSČ', max_length=32, required=False) @@ -135,8 +142,8 @@ class ProfileEditForm(forms.Form): pohlavi_muz = forms.ChoiceField(label='Pohlaví', choices = ((True,'muž'),(False,'žena')), required=True) email = forms.EmailField(label='E-mail',max_length=256, required=True) - telefon = forms.CharField(label='Telefon',max_length=256, required=False) - datum_narozeni = forms.DateField(label='Datum narození', required=False) + telefon = forms.CharField(widget=TelInput(),label='Telefon',max_length=256, required=False) + datum_narozeni = forms.DateField(widget=DateInput(),label='Datum narození', required=False) ulice = forms.CharField(label='Ulice', max_length=256, required=False) mesto = forms.CharField(label='Město', max_length=256, required=False) psc = forms.CharField(label='PSČ', max_length=32, required=False) @@ -234,7 +241,7 @@ class VlozReseniForm(forms.Form): #resitele = models.ManyToManyField(Resitel, verbose_name='autoři řešení', # help_text='Seznam autorů řešení', through='Reseni_Resitele') - cas_doruceni = forms.DateField(label="Čas doručení") + cas_doruceni = forms.DateField(widget=DateInput(),label="Čas doručení") #cas_doruceni = models.DateTimeField('čas_doručení', default=timezone.now, blank=True)