验证所有必填字段的表单时如何显示错误消息?

时间:2018-09-24 23:07:01

标签: jquery html

在验证所有必填字段的表单时如何显示错误消息?我目前有一个针对“ noSpace”的应用程序,但是对于所有其他错误消息,我需要一种更完善的方法。

 let messages = [
            ChatMessage.init(senderId: "1", message: "hi", date: Date()),
            ChatMessage.init(senderId: "2", message: "yo", date: Date().addingTimeInterval(1.0)),
            ChatMessage.init(senderId: "1", message: "you code bro?", date: Date().addingTimeInterval(2.0)),
            ChatMessage.init(senderId: "2", message: "fo sho", date: Date().addingTimeInterval(3.0)),
            ChatMessage.init(senderId: "1", message: "let's get a beer", date: Date().addingTimeInterval(4.0)),
            ChatMessage.init(senderId: "2", message: "nah", date: Date().addingTimeInterval(5.0)),
            ChatMessage.init(senderId: "2", message: "you can't see this, its my 4th response", date: Date().addingTimeInterval(6.0)),
        ]

let model = ConversationViewModel()
model.setChat(messages)

HTML

override func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
    return model.rowsInChat()
}

override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {

    let message = model.messageFor(indexPath)
    if message.senderId == userID {
        let cell = tableView.dequeueReusableCell(withIdentifier: "cell2", for: indexPath) as! CellTwo
        cell.load(message)
        return cell
    }
    else {
        let cell =tableView.dequeueReusableCell(withIdentifier: "cell", for: indexPath) as! ConversationTableViewCell
        cell.load(message)
        return cell
    }

}

0 个答案:

没有答案