title: Validate multiple fields from frontend using react native
body: <p>How to validate all the fields from the front end
  I have 4 fields here i have written a function on blur how can i proceed to this</p>
  
  <p>import React, { Component } from 'react'</p>
  
  <p>class Signup extends Component {</p>
  
  <pre><code>constructor(props) {
      super(props);
      this.state = {
          mobileno: '',
          email: '',
          password: '',
      }
  }
  
  hanldeValidation(text, type) {
      var mobilregex = /^[0-9]/;
  
  
      if (this.state.mobileno == '' &amp;&amp; mobilregex.test(text) == false) {
          this.setState({
              errormobile: true
          })
      }
  
      else if (this.state.email == '' &amp;&amp; emailregex.test(text) == false) {
          this.setState({
              erroremail: true
          })
      }
  }
  
  
  
  
  
  
  render() {
  
      return (
          &lt;View&gt;
  
              &lt;Content style={{
                  paddingLeft: 10,
                  paddingRight: 10,
                  backgroundColor: 'white'
              }}&gt;
  
                  &lt;View style={{ paddingTop: 35, backgroundColor: '#ffffff', width: '100%', alignItems: 'center' }}&gt;
  
  
  
                      {/*  Input Fields */}
  
                      &lt;Item  &gt;
                          &lt;Input ref="mobileno" placeholder={strings('EnterMobileno')}
                              value={this.state.mobileno}
                              onChangeText={(mobileno) =&gt; this.setState({ mobileno: mobileno })}
                              onBlur={(mobileno) =&gt; this.hanldeValidation(mobileno, 'mobileno')}
                          /&gt;
                      &lt;/Item&gt;
                      {
                          this.state.errormobile ?
                              &lt;Text style={{ textAlign: 'center', color: 'red' }}&gt;
                                  {'Enter a valid number'}
                              &lt;/Text&gt;
                              :
                              null
                      }
  
  
  
                      &lt;Item &gt;
                          &lt;Input ref="email" placeholder={'Enter Email ( optional )'}
                              value={this.state.email}
                              onChangeText={(email) =&gt; this.setState({ email: email })}
                          /&gt;
                      &lt;/Item&gt;
  
                      &lt;Item &gt;
                          &lt;Input ref="password" placeholder={'Enter password'}
                              value={this.state.password}
                              onChangeText={(password) =&gt; this.setState({ password: password })}
                          /&gt;
                      &lt;/Item&gt;
  
  
  
                      {/* Signup Button */}
                      &lt;Button block rounded
                          style={styles.loginButtonStyle}
                          onPress={() =&gt; this.props.createUser(this.state)}
                      &gt;
                          Signup
        &lt;/Button&gt;
  
                  &lt;/View&gt;
  
              &lt;/Content&gt;
  
          &lt;/View &gt;
      )
  }
  </code></pre>
  
  <p>}</p>
  
  <p>const mapStateToProps = (state) => {</p>
  
  <p>}</p>
  
  <p>const mapDispatchToProps = (dispatch) => {</p>
  
  <p>}</p>
  
  <p>export default (SignupScreen)</p>