176
rated 0 times
[
182]
[
6]
/ answers: 1 / hits: 21552
/ 6 Years ago, wed, february 14, 2018, 12:00:00
How to stop entering whitespace in password input field in React Native?
password
might be any characters including space.
I tried this: validator.js
const extract = (str, pattern) => (str.match(pattern) || []).pop() || '';
export function removeWhiteSpace(str) {
return extract(str, '/^S*$/;');
}
login.js
passwordHandle(value){
this.setState({
password:removeWhiteSpace(value)
})
console.log(removeWhiteSpace(value))
}
render()
<View style={{paddingBottom:25}}>
<TextField
label='Password'
type='password'
value={password}
error={errors.password}
icon
onChange={this.passwordHandle}/>
<Image
source={require('../../../assets/img/lock.png')}
style={styles.icon} />
</View>
But it doesn't work.
It only executes the '/^S*$/;' from removeWhiteSpace
.
More From » reactjs