diff --git a/Gui/AddContact.qml b/Gui/AddContact.qml index c925bcd..6e37ff7 100644 --- a/Gui/AddContact.qml +++ b/Gui/AddContact.qml @@ -117,6 +117,7 @@ GridLayout text: qsTr("Geburtsdatum") Layout.alignment: Qt.AlignRight } + TextField { property string name: "birthday" @@ -124,16 +125,21 @@ GridLayout Layout.fillWidth: true placeholderText: qsTr("TT.MM.JJJJ") validator: RegularExpressionValidator + { - regularExpression: /((^|)([0-2]{1}[0-9]{1}|3[0-1]))\.((^|)(0[1-9]{1}|1[0-2]{1}))\.((^|)(196[0-9]{1}|19[7-9]{1}[0-9]{1}|20[0-9]{2}))/ + regularExpression: /((^|)(0[1-9]{1}|[1-2]{1}[0-9]{1}|3[0-1]))\.((^|)(0[1-9]{1}|1[0-2]{1}))\.((^|)(196[0-9]{1}|19[7-9]{1}[0-9]{1}|20[0-9]{2}))/ + } + Keys.onPressed: (event)=> + { + if (event.key !== Qt.Key_Backspace) + { + var len = birthday.length + var bd = birthday.text + if (len === 2 || len === 5) birthday.text = bd + "." + } + } - onTextChanged: - { - var len = birthday.length - var bd = birthday.text - if (len == 2 || len == 5) birthday.text = bd + "." - } } Label