Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion kivymd/uix/textfield/textfield.py
Original file line number Diff line number Diff line change
Expand Up @@ -457,6 +457,13 @@ class Validator:
:attr:`date_format` is an :class:`~kivy.properties.OptionProperty`
and defaults to `None`.
"""
def is_number_valid(self, text: str) -> bool:
"""Checks the validity of a number."""
for i in text:
if not i.isdigit():
return True
break
return False

def is_email_valid(self, text: str) -> bool:
"""Checks the validity of the email."""
Expand Down Expand Up @@ -1489,7 +1496,7 @@ class MDTextField(
defaults to ''.
"""

validator = OptionProperty(None, options=["date", "email", "time", "phone"])
validator = OptionProperty(None, options=["date", "email", "time", "phone", "number"])
"""
The type of text field for entering Email, time, etc.
Automatically sets the type of the text field as "error" if the user input
Expand Down Expand Up @@ -2539,6 +2546,7 @@ def _get_has_error(self) -> bool:
"date": self.is_date_valid,
"email": self.is_email_valid,
"time": self.is_time_valid,
"number": self.is_number_valid,
}[self.validator](self.text)
return has_error
if (
Expand Down