title: How to validate email and password on click of submit button in React native?
body: <p>I'm new to react-native and by following the docs I have created a simple login screen. Now I'm not getting how to validate input fields on click of submit button. Below is the code for login screen.</p>
  
  <pre><code>import React, { Component } from 'react';
  import {
    AppRegistry,
    Text,
    Image,
    View,
    Button,
    StyleSheet,
    TextInput,
    Linking,
    Alert
  } from 'react-native';
  
  class LoginPage extends Component {
  //On click of submit button alert will appear
    _onSubmit() {
      Alert.alert('Button has been pressed!');
    }
    render() {
      return (
        &lt;View style={styles.containerView}&gt;
          &lt;Text style={styles.loginText} &gt;
            Username or Email
          &lt;/Text&gt;
          &lt;TextInput style={styles.inputFields}
            placeholder="e.g: abc@example.com" /&gt;
          &lt;Text style={styles.loginText}&gt;
            Password
          &lt;/Text&gt;
          &lt;TextInput style={styles.inputFields}
            placeholder="Password"
            secureTextEntry={true} /&gt;
          &lt;Text style={{color: 'blue', marginBottom: 10}}
            onPress={() =&gt; Linking.openURL('https://www.google.co.in')}&gt;
            Forgot Password?
          &lt;/Text&gt;
          &lt;Button
              onPress={this._onSubmit}
              title="Login"
              style={styles.loginButton}
              accessibilityLabel="Ok, Great!"
            /&gt;
        &lt;/View&gt;
      );
    }
  };
  
  //Stylesheet for input fields
  const styles= StyleSheet.create({
    containerView: {
      flex: 1,
      justifyContent: 'center',
      backgroundColor: '#ffebcd',
      borderStyle: 'solid',
      borderColor: '#000000'
    },
    loginText: {
      fontSize: 20,
      marginBottom: 10
    },
    inputFields: {
      fontSize: 20,
      borderStyle: 'solid',
      borderColor: '#000000',
      borderRadius: 30,
      marginBottom: 10
    },
    loginButton: {
      backgroundColor: '#34A853'
    }
  });
  
  AppRegistry.registerComponent('AwesomeProject', () =&gt; LoginPage);
  </code></pre>