【发布时间】:2020-06-15 09:55:48
【问题描述】:
我想为电话号码进行文本输入,该值必须仅为数字且最小长度为 7,另一个文本输入是用于电子邮件,该值必须具有“@”。如果电话和电子邮件文本输入值不适合该条件,我想给出一些警告。
<Text
style={{
marginTop: 10,
marginLeft: 0,
textAlign: 'auto',
fontWeight: 'bold',
}}>
Phone Number :
</Text>
<Item>
<Input
placeholder=""
style={{ fontSize: 14, borderColor: '#00468c', borderWidth: 1, marginTop: 8 }}
placeholderTextColor='#cfcfcf'
onChangeText={valueNoHP => {
this.setState({ valueNoHP })
console.log("Ini: " + valueNoHP)
}}
value={this.state.valueNoHP}
keyboardType='number-pad'
minLength={7}
/>
</Item>
<Text
style={{
marginTop: 10,
marginLeft: 0,
textAlign: 'auto',
fontWeight: 'bold',
}}>
Email Address :
</Text>
<Item>
<Input autoCapitalize='none' placeholder="" style={{ fontSize: 14, borderColor: '#00468c', borderWidth: 1, marginTop: 8 }} placeholderTextColor='#cfcfcf'
onChangeText={valueEmail => this.setState({ valueEmail })}
value={this.state.valueEmail}
keyboardType='email-address'
/>
</Item>
【问题讨论】: