Commit addfd7c5 authored by Steven杜宇's avatar Steven杜宇

// 字符限制

parent c6f8e424
...@@ -210,6 +210,24 @@ extension YHEducationDetailVC : UITableViewDelegate, UITableViewDataSource { ...@@ -210,6 +210,24 @@ extension YHEducationDetailVC : UITableViewDelegate, UITableViewDataSource {
cell.isMust = detailItem.isNeed cell.isMust = detailItem.isNeed
cell.title = detailItem.getTitle() cell.title = detailItem.getTitle()
cell.text = detailItem.value cell.text = detailItem.value
cell.textInputCondtion = {
textField in
var max = -1
if detailItem.type == .educationMajor ||
detailItem.type == .educationCity {
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 }
......
...@@ -184,6 +184,24 @@ extension YHQualificationDetailVC : UITableViewDelegate, UITableViewDataSource { ...@@ -184,6 +184,24 @@ extension YHQualificationDetailVC : UITableViewDelegate, UITableViewDataSource {
cell.isMust = detailItem.isNeed cell.isMust = detailItem.isNeed
cell.title = detailItem.getTitle() cell.title = detailItem.getTitle()
cell.text = detailItem.value cell.text = detailItem.value
cell.textInputCondtion = {
textField in
var max = -1
if detailItem.type == .conferAgencyFullName ||
detailItem.type == .conferCity {
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 }
......
...@@ -98,6 +98,9 @@ class YHCollegeSearchBar: UIView { ...@@ -98,6 +98,9 @@ class YHCollegeSearchBar: UIView {
} }
@objc func textFieldChanged(textField:UITextField) { @objc func textFieldChanged(textField:UITextField) {
let text = textField.text ?? ""
let max = 100
textField.text = (text.count > max ? text[safe: ..<max] : text)
if let textChange = textChange { if let textChange = textChange {
textChange(textField.text) textChange(textField.text)
} }
......
...@@ -154,7 +154,12 @@ extension YHCertificateInfoController : UITableViewDelegate, UITableViewDataSour ...@@ -154,7 +154,12 @@ extension YHCertificateInfoController : UITableViewDelegate, UITableViewDataSour
cell.placeHolder = detailItem.placeHolder cell.placeHolder = detailItem.placeHolder
cell.title = detailItem.getTitle() cell.title = detailItem.getTitle()
cell.text = detailItem.value cell.text = detailItem.value
cell.setTips(detailItem.tips, isShow: isNeedShowError && detailItem.isNeed && detailItem.isShowTips) if detailItem.type == .chinaIdentityCardNumber {
cell.setTips(detailItem.tips, isShow: isNeedShowError && detailItem.isNeed && detailItem.value?.count != 18)
} else {
cell.setTips(detailItem.tips, isShow: isNeedShowError && detailItem.isNeed && detailItem.isShowTips)
}
cell.textInputCondtion = { cell.textInputCondtion = {
textField in textField in
...@@ -162,7 +167,7 @@ extension YHCertificateInfoController : UITableViewDelegate, UITableViewDataSour ...@@ -162,7 +167,7 @@ extension YHCertificateInfoController : UITableViewDelegate, UITableViewDataSour
if detailItem.type == .chinaIdentityCardNumber { // 身份证 if detailItem.type == .chinaIdentityCardNumber { // 身份证
max = 18 max = 18
} else if detailItem.type == .certificateSignPlace { // 签发地 } else if detailItem.type == .certificateSignPlace { // 签发地
max = 100 max = 50
} else if detailItem.type == .traverlPassportNumber || } else if detailItem.type == .traverlPassportNumber ||
detailItem.type == .certificateNumber { detailItem.type == .certificateNumber {
max = 50 max = 50
...@@ -379,7 +384,7 @@ extension YHCertificateInfoController : UITableViewDelegate, UITableViewDataSour ...@@ -379,7 +384,7 @@ extension YHCertificateInfoController : UITableViewDelegate, UITableViewDataSour
let isChinaCardMust = familyMember.isChinese() && familyMember.relationType != .child let isChinaCardMust = familyMember.isChinese() && familyMember.relationType != .child
if isChinaCardMust { if isChinaCardMust {
if familyMember.certificates.cnIdentityCard.number.count <= 0 if familyMember.certificates.cnIdentityCard.number.count != 18
|| familyMember.certificates.cnIdentityCard.issueAt.count <= 0 || familyMember.certificates.cnIdentityCard.issueAt.count <= 0
|| familyMember.certificates.cnIdentityCard.issueDateStartAt.count <= 0 || familyMember.certificates.cnIdentityCard.issueDateStartAt.count <= 0
|| familyMember.certificates.cnIdentityCard.issueDateEndAt.count <= 0 || familyMember.certificates.cnIdentityCard.issueDateEndAt.count <= 0
......
...@@ -265,11 +265,18 @@ extension YHChildBasicInfoVC : UITableViewDelegate, UITableViewDataSource { ...@@ -265,11 +265,18 @@ 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)
if detailItem.type == .befourMarryFirstName {
cell.textField.keyboardType = .asciiCapable // 英文键盘
} else {
cell.textField.keyboardType = .default
}
cell.textInputCondtion = { cell.textInputCondtion = {
textField in textField in
if detailItem.type == .befourMarryFirstName { // 仅支持输入最多30个大写字母 if detailItem.type == .befourMarryFirstName { // 仅支持输入最多30个大写字母
let regex = "[^A-Z]+" let regex = "[^A-Za-z]+"
textField.limitInputWithPattern(pattern:regex, 30) textField.limitInputWithPattern(pattern:regex, 30)
return true return true
} }
...@@ -302,7 +309,10 @@ extension YHChildBasicInfoVC : UITableViewDelegate, UITableViewDataSource { ...@@ -302,7 +309,10 @@ extension YHChildBasicInfoVC : UITableViewDelegate, UITableViewDataSource {
self.child?.usedName = text ?? "" self.child?.usedName = text ?? ""
} else if detailItem.type == .befourMarryFirstName { } else if detailItem.type == .befourMarryFirstName {
self.child?.surname = text ?? "" let tt = text?.uppercased()
self.child?.surname = tt ?? ""
cell.textField.text = tt
} else if detailItem.type == .birthCity { } else if detailItem.type == .birthCity {
self.child?.birthPlace.foreign = text ?? "" self.child?.birthPlace.foreign = text ?? ""
......
...@@ -391,11 +391,18 @@ extension YHSpouseBasicInfoVC : UITableViewDelegate, UITableViewDataSource { ...@@ -391,11 +391,18 @@ extension YHSpouseBasicInfoVC : UITableViewDelegate, UITableViewDataSource {
} else { } else {
cell.setTips(detailItem.tips, isShow: isNeedShowError && detailItem.isShowTips) cell.setTips(detailItem.tips, isShow: isNeedShowError && detailItem.isShowTips)
} }
if detailItem.type == .befourMarryFirstName {
cell.textField.keyboardType = .asciiCapable // 英文键盘
} else {
cell.textField.keyboardType = .default
}
cell.textInputCondtion = { cell.textInputCondtion = {
textField in textField in
if detailItem.type == .befourMarryFirstName { // 仅支持输入最多30个大写字母 if detailItem.type == .befourMarryFirstName { // 仅支持输入最多30个大写字母
let regex = "[^A-Z]+" let regex = "[^A-Za-z]+"
textField.limitInputWithPattern(pattern:regex, 30) textField.limitInputWithPattern(pattern:regex, 30)
return true return true
} }
...@@ -425,7 +432,12 @@ extension YHSpouseBasicInfoVC : UITableViewDelegate, UITableViewDataSource { ...@@ -425,7 +432,12 @@ extension YHSpouseBasicInfoVC : UITableViewDelegate, UITableViewDataSource {
} else if detailItem.type == .everName { } else if detailItem.type == .everName {
self.spouse?.usedName = text ?? "" self.spouse?.usedName = text ?? ""
} else if detailItem.type == .befourMarryFirstName { } else if detailItem.type == .befourMarryFirstName {
self.spouse?.surname = text ?? ""
let tt = text?.uppercased()
self.spouse?.surname = tt ?? ""
cell.textField.text = tt
} else if detailItem.type == .birthCity { } else if detailItem.type == .birthCity {
self.spouse?.birthPlace.foreign = text ?? "" self.spouse?.birthPlace.foreign = text ?? ""
} else if detailItem.type == .occupationName { } else if detailItem.type == .occupationName {
......
...@@ -306,7 +306,7 @@ extension YHFamilyMemberInfoListVC { ...@@ -306,7 +306,7 @@ extension YHFamilyMemberInfoListVC {
if let errMsg = error?.errorMsg, errMsg.count > 0 { if let errMsg = error?.errorMsg, errMsg.count > 0 {
errorMsg = errMsg errorMsg = errMsg
} }
YHHUD.flash(message: errorMsg) YHHUD.flash(message: errorMsg, duration:3)
} }
} }
} }
......
...@@ -69,7 +69,7 @@ class YHFormItemInputTextCell: UITableViewCell { ...@@ -69,7 +69,7 @@ class YHFormItemInputTextCell: UITableViewCell {
return label return label
}() }()
private lazy var textField:UITextField = { lazy var textField:UITextField = {
let textField = UITextField() let textField = UITextField()
textField.backgroundColor = .clear textField.backgroundColor = .clear
textField.placeholder = "请输入" textField.placeholder = "请输入"
......
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