Commit 3e32816d authored by Steven杜宇's avatar Steven杜宇

// 字数限制

parent ab4fbb8c
...@@ -263,6 +263,32 @@ extension YHChildBasicInfoVC : UITableViewDelegate, UITableViewDataSource { ...@@ -263,6 +263,32 @@ extension YHChildBasicInfoVC : UITableViewDelegate, UITableViewDataSource {
cell.title = detailItem.getTitle() cell.title = detailItem.getTitle()
cell.text = detailItem.value cell.text = detailItem.value
cell.setTips(detailItem.tips, isShow: isNeedShowError && detailItem.isShowTips) cell.setTips(detailItem.tips, isShow: isNeedShowError && detailItem.isShowTips)
cell.textInputCondtion = {
textField in
if detailItem.type == .befourMarryFirstName { // 仅支持输入最多30个大写字母
let regex = "[^A-Z]+"
textField.limitInputWithPattern(pattern:regex, 30)
return true
}
var max = -1
if detailItem.type == .childName ||
detailItem.type == .everName {
max = 30
} else if detailItem.type == .birthCity ||
detailItem.type == .occupationName
{
max = 100
}
if max > 0 {
if let textStr = textField.text {
textField.text = (textStr.count > max ? textStr[safe: ..<max] : textStr)
}
}
return true
}
cell.textChange = { cell.textChange = {
[weak self] (text, isEditEnd) in [weak self] (text, isEditEnd) in
guard let self = self else { return } guard let self = self else { return }
......
...@@ -389,7 +389,32 @@ extension YHSpouseBasicInfoVC : UITableViewDelegate, UITableViewDataSource { ...@@ -389,7 +389,32 @@ extension YHSpouseBasicInfoVC : UITableViewDelegate, UITableViewDataSource {
} else { } else {
cell.setTips(detailItem.tips, isShow: isNeedShowError && detailItem.isShowTips) cell.setTips(detailItem.tips, isShow: isNeedShowError && detailItem.isShowTips)
} }
cell.textInputCondtion = {
textField in
if detailItem.type == .befourMarryFirstName { // 仅支持输入最多30个大写字母
let regex = "[^A-Z]+"
textField.limitInputWithPattern(pattern:regex, 30)
return true
}
var max = -1
if detailItem.type == .spouseName ||
detailItem.type == .everName {
max = 30
} else if detailItem.type == .birthCity ||
detailItem.type == .occupationName
{
max = 100
}
if max > 0 {
if let textStr = textField.text {
textField.text = (textStr.count > max ? textStr[safe: ..<max] : textStr)
}
}
return true
}
cell.textChange = { cell.textChange = {
[weak self] (text, isEditEnd) in [weak self] (text, isEditEnd) in
guard let self = self else { return } guard let self = self else { return }
......
...@@ -234,6 +234,23 @@ extension YHBrotherInfoVC : UITableViewDelegate, UITableViewDataSource { ...@@ -234,6 +234,23 @@ extension YHBrotherInfoVC : UITableViewDelegate, UITableViewDataSource {
} else { } else {
cell.setTips(detailItem.tips, isShow: isNeedShowError && detailItem.isShowTips) cell.setTips(detailItem.tips, isShow: isNeedShowError && detailItem.isShowTips)
} }
cell.textInputCondtion = {
textField in
var max = -1
if detailItem.type == .brotherName {
max = 30
} else if detailItem.type == .birthCity {
max = 100
}
if max > 0 {
if let textStr = textField.text {
textField.text = (textStr.count > max ? textStr[safe: ..<max] : textStr)
}
}
return true
}
cell.textChange = { cell.textChange = {
[weak self] (text, isEditEnd) in [weak self] (text, isEditEnd) in
......
...@@ -171,8 +171,6 @@ extension YHCertificateInfoController : UITableViewDelegate, UITableViewDataSour ...@@ -171,8 +171,6 @@ extension YHCertificateInfoController : UITableViewDelegate, UITableViewDataSour
textField.text = (textStr.count > max ? textStr[safe: ..<max] : textStr) textField.text = (textStr.count > max ? textStr[safe: ..<max] : textStr)
} }
} }
return true return true
} }
cell.textChange = { cell.textChange = {
......
...@@ -276,6 +276,26 @@ extension YHParentInfoVC : UITableViewDelegate, UITableViewDataSource { ...@@ -276,6 +276,26 @@ extension YHParentInfoVC : UITableViewDelegate, UITableViewDataSource {
} else { } else {
cell.setTips(detailItem.tips, isShow: isNeedShowError && detailItem.isShowTips) cell.setTips(detailItem.tips, isShow: isNeedShowError && detailItem.isShowTips)
} }
cell.textInputCondtion = {
textField in
var max = -1
if detailItem.type == .fatherName ||
detailItem.type == .motherName {
max = 30
} else if detailItem.type == .birthCity ||
detailItem.type == .occupationName
{
max = 100
}
if max > 0 {
if let textStr = textField.text {
textField.text = (textStr.count > max ? textStr[safe: ..<max] : textStr)
}
}
return true
}
cell.textChange = { cell.textChange = {
[weak self] (text, isEditEnd) in [weak self] (text, isEditEnd) in
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment