# React Native text input, datepicker and dropdown values

**URL:** https://forum.codewithmosh.com/t/react-native-text-input-datepicker-and-dropdown-values/73310
**Category:** React Native
**Created:** [September 24, 2026, 12:16pm UTC](https://forum.codewithmosh.com/t/react-native-text-input-datepicker-and-dropdown-values/73310 "2026-09-24T12:16:42Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![mynixmail.fever](https://avatars.discourse-cdn.com/v4/letter/m/67e7ee/32.png) [@mynixmail.fever](https://forum.codewithmosh.com/u/mynixmail.fever)
#### Post date: [September 24, 2026, 12:16pm UTC](https://forum.codewithmosh.com/t/react-native-text-input-datepicker-and-dropdown-values/73310/1 "2026-09-24T12:16:42Z")

</div>

![screenshot](https://us1.discourse-cdn.com/flex020/uploads/codewithmosh/original/2X/0/06be9aefeb4b52e17c42d68e6a1b79a8c9a93bbf.png)

Just started to learn React Native with expo (small steps at a time). I have a screen setup (as per the screenshot) whereby I want to display the values of each textInput, selected date and dropdown with an alert popup.

At the moment when I select a date it does nothing. And my code is complete spaghetti.

```auto
import { Alert, Pressable, ScrollView, StyleSheet, Text, TextInput, View } from 'react-native';
import React, { useState } from 'react';
import { Link } from 'expo-router';
import { useSafeAreaInsets } from 'react-native-safe-area-context';
import { Dropdown } from 'react-native-element-dropdown';
import DatePicker from 'react-native-ui-datepicker';
import globalStyles from '../styles/globalStyles';
import dayjs from 'dayjs';

export default function TabTwoScreen() {
    ////////////////////For text imput////////////////////
    const [formData, setFormData] = useState({ description: '', serialNumber: '', });
    const handleInputChange = (key, value) => {
        setFormData((prevData) => ({
        ...prevData,
        [key]: value, // Dynamically updates the specific key
        }));
    };
    const handleSubmit = () => {
        if (!dateText) {
            Alert.alert("Validation Error", "Please select a date before submitting.");
            return;
        }
        Alert.alert('Submitted Data', JSON.stringify(formData));
    };
    ////////////////////For date////////////////////
    const [date, setDate] = useState(new Date());
    const [open, setOpen] = useState(false);
    const [dateText, setDateText] = useState('');
    const formatDate = (rawDate) => {
        let d = new Date(rawDate);
        let day = String(d.getDate()).padStart(2, '0');
        let month = String(d.getMonth() + 1).padStart(2, '0'); // Months are 0-indexed
        let year = d.getFullYear();
        return `${year}-${month}-${day}`; // Format: YYYY-MM-DD
    };
   ////////////////////For dropdown list////////////////////
    const [value, setValue] = useState<string | null>(null);
    const stations = [
        { label: 'City 1', value: '1' },
        { label: 'City 2', value: '2' },
        { label: 'City 3', value: '3' },
        { label: 'City 4', value: '4' },
        ];

  return (
    <ScrollView style={styles.scrollView}>

        <View style={styles.textInputContainer}>
        
            <TextInput
                style={globalStyles.input}
                placeholder="Description"
                value={formData.description}
                onChangeText={(text) => handleInputChange('description', text)}
            />
            
            <TextInput
                style={globalStyles.input}
                placeholder="Serial Number"
                value={formData.serialNumber}
                onChangeText={(text) => handleInputChange('serialNumber', text)}
            />

            <Text style={globalStyles.textInputDescription}>EXPIRY DATE:</Text>

            <DatePicker
                modal
                open={open}
                date={date}
                mode="single"
// minDate={dayjs().subtract(7, 'days')}
// maxDate={dayjs().add(1, 'year')}
                onConfirm={(selectedDate) => {
          setOpen(false); //
          setDate(selectedDate); //
          setDateText(formatDate(selectedDate)); // Update text input display
        }}
        onCancel={() => {
          setOpen(false); //
        }}
            />
        
            <Dropdown
                style={styles.dropdownList}
                data={stations}
                labelField="label"
                valueField="value"
                placeholder="Select Station"
                value={value}
                onChange={item => { setValue(item.value);
                }}
            />
        
            <Link href="/screens/addTool" style={{ marginHorizontal: 'auto' }}
                asChild>
                <Pressable onPress={handleSubmit} style={globalStyles.pressable}>
                <Text style={globalStyles.pressableText}>Add a Tool</Text>
                </Pressable>
            </Link>

        </View>

    </ScrollView>
  );
}

const styles = StyleSheet.create({
  scrollView: {
    marginTop:20,
    flex: 1,
  },
  textInputContainer: {
    justifyContent: 'center',
    alignItems: 'center',
    gap: 6,
  },
  dropdownList: {height: 50,
    borderColor: 'gray',
    borderWidth: 0.5,
    borderRadius: 8,
    paddingHorizontal: 8,
    width: '90%',
  }
});

```

Also, in the below screenshots I have some red underlined keywords.

 ![error1](https://us1.discourse-cdn.com/flex020/uploads/codewithmosh/original/2X/9/9f15563fb7ff7a23ad360b76e8df3771b36016c8.png)

 ![error2](https://us1.discourse-cdn.com/flex020/uploads/codewithmosh/original/2X/5/5bea494ef25bc411a0b74d1b67df1766eed13173.png)

 ![error3](https://us1.discourse-cdn.com/flex020/uploads/codewithmosh/original/2X/0/0aeeb24b20cfc9d9231b1129f8dcba5914bd6ce7.png)

Here are my styles

```auto
import { View, Pressable, Text, StyleSheet, ImageBackground } from 'react-native';

const globalStyles = StyleSheet.create({
  indexPageSelectionContainer: {
    flex: 1,
    flexDirection: 'column',
    justifyContent: 'center',
    alignItems: 'center',
    backgroundColor: "#ffffff",
    gap: 16,
  },
  bgImage: {
    width: '100%',
    height: '100%',
    flex: 1,
    resizeMode: 'cover',
    justifyContent: 'center',
  },
  link: {
    color: 'white',
    fontSize: 42,
    fontWeight: 'bold',
    textAlign: 'center',
    backgroundColor: 'rgba(0,0,0,2)',
    textDecorationLine: 'underline',
    backgroundColor: 'rgba(0,0,0,5)',
    padding: 4,
  },
  title: {
    color: 'white',
    fontSize: 42,
    fontWeight: 'bold',
    textAlign: 'center',
    backgroundColor: 'rgba(0,0,0,0.5)',
    marginBottom: 120,
  },
  pressable: {
    height: 40,
    borderRadius: 10,
    justifyContent: 'center',
    backgroundColor: 'rgba(0,0,0,0.25)',
    padding: 2,
    width: '90%',
    borderWidth: 0,
    borderColor: 'red',
  },
  pressableText: {
    color: '#000000',
    fontSize: 16,
    fontWeight: 'bold',
    textAlign: 'left',
    padding: 4,
  },
  input: {
    color: 'black',
    height:48,
    borderWidth: 1,
    borderColor: '#c0c0c0',
    borderRadius: 8,
    paddingHorizontal: 12,
    backgroundColor: '#ffffff',
    fontSize: 12,
    width: '90%',
  },
  textInputDescription: {
    fontWeight: 'bold',
    textAlign: 'left',
  },
  pressed: {
    opacity: 0.7,
  }
})

export default globalStyles

```
