Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/svn/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
React native 如果输入多个空格,则检查文本输入是否为空失败_React Native - Fatal编程技术网

React native 如果输入多个空格,则检查文本输入是否为空失败

React native 如果输入多个空格,则检查文本输入是否为空失败,react-native,React Native,我正在使用来自react native的TextInput。这里我不需要允许用户输入多个空间。下面是代码。对于空白,它允许用户继续提交 参考代码 可以使用trim函数删除字符串开头和结尾的额外空格。像这样改变你的条件: if (this.state.TextInputName.trim() != '') 及 if (this.state.TextInputEmail.trim() != '')

我正在使用来自react native的TextInput。这里我不需要允许用户输入多个空间。下面是代码。对于空白,它允许用户继续提交

参考代码

可以使用trim函数删除字符串开头和结尾的额外空格。像这样改变你的条件:

if (this.state.TextInputName.trim() != '')

if (this.state.TextInputEmail.trim() != '')