For one category i have added extra row in tableview, but i am unable to validate its textfield text value.
this code:
var finalSearchValue : String = ""
var finalSearchValueAmnt : String = ""
var cell : BillerTableViewCell?
here i have added extra row Amount, but i am unable to validate that textfield
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
if indexPath.section == 0 {
cell = tableView.dequeueReusableCell(withIdentifier: "textfieldCell", for: indexPath) as? BillerTableViewCell
cell?.searchTextfield.delegate = self
if self.rowCount! - 1 >= indexPath.row
{
if let customerDetail = selectedBiller?.bcustomerparms[indexPath.row] {
alertParam = customerDetail.paramName
cell?.searchTextfield.text = alertParam
if var priceOfProduct: String = customerDetail.minLength {
alertMinL = Int(priceOfProduct)
}
if var priceOfProduct: String = customerDetail.maxLength {
alertMaxL = Int(priceOfProduct)
}
cell?.searchTextfield.addTarget(self, action: #selector(searchPhoneEditingChanged(textField:)), for: .editingChanged)
}
else{
print("no tf")
cell?.searchTextfield.text = "missing"
}
}
else{
cell?.searchTextfield.text = "Amount"
cell?.searchTextfield.addTarget(self, action: #selector(searchAmountEditingChanged(textField:)), for: .editingChanged)
}
}
return cell!
}
@objc func searchPhoneEditingChanged(textField: UITextField) {
finalSearchValue = textField.text!
self.textCount = self.finalSearchValue.count
}
@objc func searchAmountEditingChanged(textField: UITextField) {
finalSearchValueAmnt = textField.text!
}
this is butoonaction: if there is no extra row then also it says please enter amount, if there no added row then i dont need enter amount alert, i want enter amount alert only if there is added row
@objc func buttonClicked(sender: UIButton) {
//let buttonRow = sender.tag
print("in newbiller search button")
print("the amount value \(finalSearchValueAmnt)")
print("the phone value \(finalSearchValue)")
if self.finalSearchValue.isEmpty{
AlertFun.ShowAlert(title: "", message: "Please enter \(self.alertParam!)", in: self)
}
else if self.textCount ?? 0 < self.alertMinL ?? 0{
AlertFun.ShowAlert(title: "", message: "\(self.alertParam!) not lessthen \(self.alertMinL!)", in: self)
}
else if self.textCount ?? 0 > self.alertMaxL ?? 0{
AlertFun.ShowAlert(title: "", message: "\(self.alertParam!) not graterthen \(self.alertMaxL!)", in: self)
}
if self.finalSearchValueAmnt.isEmpty{
AlertFun.ShowAlert(title: "", message: "Please enter Amount", in: self)
}
else{
billerFetchService()
}
}
please help me in the above code, to validate added row textfield.
Aucun commentaire:
Enregistrer un commentaire