Skip to content
Snippets Groups Projects
Commit 06527c31 authored by Maximilian Betz's avatar Maximilian Betz
Browse files

validator still not as expected

parent 74bacee3
No related branches found
No related tags found
No related merge requests found
......@@ -156,22 +156,26 @@ class _AddEventPageState extends State<AddEvent> {
const SizedBox(height: 10.0),
TextFormField(
initialValue: eventsStore.currentEvent.label,
autovalidateMode: AutovalidateMode.onUserInteraction,
autovalidateMode: AutovalidateMode.always,
decoration: const InputDecoration(
border: OutlineInputBorder(),
labelText: 'Label',
errorText: 'Only: a-z , A-Z , _ , 0-9 , ,(Comma) , ( , ) , + , - , . , :'
),
onChanged: (value) {
},
onFieldSubmitted: (value){
eventsStore.currentEvent.label = value;
setState(() {});
},
validator: (value) {
if (!RegExp(r'^[a-z A-Z . \- 0-9 , ( ) + - _ :]+$').hasMatch(
value!)) {
return "Only: a-z , A-Z , _ , 0-9 , ,(Comma) , ( , ) , + , - , . , :";
} else {
eventsStore.currentEvent.label = value;
return ''; // Entered Text is valid
//eventsStore.currentEvent.label = value;
return ""; // Entered Text is valid
}
},
),
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment