react-native - undefined is not an object (evaluating '_this.state.BankName.trim') in react native
问题描述
I want input field should not be an empty. please help me I am getting this error = undefined is not an object (evaluating '_this.state.BankName.trim')
here is my code
if (!this.state.BankName.trim())
// if (!/^$|^.*@.*\..*$/.test(this.state.BankName))
{
this.setState({ BankNameError: 'Field Should Not Be An Empty' })
return;
}
else {
Alert.alert("All fields validated")
return;
}
}
handleBankName = (text) => {
this.setState({ BankNameError: '' })
this.setState({ BankName: text })
}
<TextInput maxLength={20} placeholder="Name of Bank*" style={styles.inputStyle}
onChangeText={this.handleBankName} />
<Text>{this.state.BankNameError}</Text>
解决方案
推荐阅读
- html - 如何在 iphone 的灯光模式下保持电子邮件模板 [Newsletter] 相同的背景
- python - 如何解决 Pandas Dataframe 中的格式错误 - 长度问题或格式?
- asp.net - SqlException:列名“NormalizedName”无效。列名“ConcurrencyStamp”无效。列名“NormalizedName”无效
- arrays - Spark:从 Scala 中的嵌套数组中删除第一个数组
- html - 如何使用 Bootstrap 4 在 div 旁边放置链接按钮
- xamarin.android - textview 可见性 xamarin android
- php - 规范化/标准路径根到 CLI/WEB
- java - 来自适配器类的访问意图
- bash - 如何在 shell 别名的每个参数之前添加“-e”?
- java - 使用抽象源 [java] 进行数据访问 - 用于傻瓜