Skip to content

Commit

Permalink
validator for roll number
Browse files Browse the repository at this point in the history
  • Loading branch information
chanchalyadav272 committed Jun 29, 2023
1 parent 305f98b commit 17b3bb7
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions lib/pages/profile/edit_profile.dart
Original file line number Diff line number Diff line change
Expand Up @@ -303,9 +303,17 @@ class _EditProfileState extends State<EditProfile> {
),
CustomTextField(
hintText: 'Roll Number',
// validator: validatefield,
validator: (String? value) {
if (value == null || value.isEmpty) {
return 'Field cannot be empty';
}
else if(value.length!=9){
return 'Enter valid roll number';
}
return null;
},
inputFormatters: [FilteringTextInputFormatter.digitsOnly,],
isNecessary: false,
isNecessary: true,
controller: _rollController,
maxLength: 9,
maxLines: 1,
Expand Down

0 comments on commit 17b3bb7

Please sign in to comment.