swift - 使用天空浮动标签在文本字段上显示验证错误
问题描述
嗨,我skyfloatinglabel
在我的应用程序中使用文本字段。我想在文本字段上显示错误。
我编写验证,如下所示它会显示错误,但它会移动到下一个屏幕如何控制它。
请找出以下错误:
fullnametxt.text == " "
func authendication()
{
let phoneNumber = phoneNumbertxt.text ?? ""
let emailAddress = emailaddresstxt.text ?? ""
let lastName = lastnametxt.text ?? ""
let fullName = fullnametxt.text ?? ""
// User Must Give The input for saving.
if (phoneNumber.isEmpty) && (emailAddress.isEmpty) && (lastName.isEmpty) && (fullName.isEmpty)
{
phoneNumbertxt.errorMessage = "Enter email address."
//self.showAlert("Alert!", "Fill All The Fields", "ok")
}
else if fullnametxt.text == " "
{
//self.showAlert("Alert!", "Must Fill The FullName", "ok")
fullnametxt.errorMessage = "Full name"
fullnametxt.errorColor = UIColor.appcolorlight
}
}
解决方案
fullnametxt.text == " "
. 在此检查" "
中,这不是空字符串,它包含空格。因为空字符串是 this ""
。
推荐阅读
- reactjs - 单个调度中的多个操作(React-Redux Hooks)
- reactjs - 工具提示 - 输入延迟无法正常工作
- cyclejs - Cycle.js:获取流,期待 Blob
- javascript - 使用 Reactjs 在画布上绘制图像后无法将画布转换为图像
- amazon-web-services - AWS EFS 上的客户端连接数?
- spring - 为什么 sortBy 的排序不同于 Kotlin 中的流排序?
- node.js - .env 为多个文件返回 undefined
- java - 以错误的顺序显示消息
- go - 文件不是 `goimports`-ed 与 -local somePath
- android - 如何仅以 10% 的增量调用 NotificationManager