-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathFirstDigit.js
More file actions
57 lines (53 loc) · 1.28 KB
/
Copy pathFirstDigit.js
File metadata and controls
57 lines (53 loc) · 1.28 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
import React from 'react';
import { TextInput, StyleSheet, View, Text } from 'react-native';
/**
* A 4-digit numeric input box for verification codes.
* @param {Object} props
* @param {string} props.value - Current code value.
* @param {function} props.onChangeText - Callback to update value.
*/
const FirstDigit = ({ value, onChangeText }) => {
const handleChange = (text) => {
const cleanedText = text.replace(/[^0-9]/g, '');
if (cleanedText.length <= 4) {
onChangeText(cleanedText);
}
};
return (
<View style={styles.inputContainer}>
<Text style={styles.label}>Enter 4-Digit Verification Code</Text>
<TextInput
style={styles.input}
placeholder=" "
value={value}
onChangeText={handleChange}
keyboardType="numeric"
maxLength={4}
autoCapitalize="none"
/>
</View>
);
};
const styles = StyleSheet.create({
inputContainer: {
marginVertical: 20,
width: 300,
},
label: {
fontSize: 16,
marginBottom: 20,
color: '#333',
textAlign: 'left',
},
input: {
height: 100,
borderWidth: 5,
borderRadius: 8,
paddingHorizontal: 12,
backgroundColor: '#fff',
width: '100%',
fontSize: 55,
borderColor: 'black',
},
});
export default FirstDigit;