i want the phone number(work Phone) format to be as shown in the below image, using react-native,can any one help how to work out it,any help much appreciated

You can achieve this with regular expressions... This will format like (555) 222-9999
onTextChange(text) {
    var cleaned = ('' + text).replace(/\D/g, '')
    var match = cleaned.match(/^(1|)?(\d{3})(\d{3})(\d{4})$/)
    if (match) {
        var intlCode = (match[1] ? '+1 ' : ''),
            number = [intlCode, '(', match[2], ') ', match[3], '-', match[4]].join('');
        this.setState({
            phoneNum: number
        });
        return;
    }
    this.setState({
        phoneNum: text
    });
}
Then on the <TextInput>...
<TextInput 
    onChangeText={(text) => this.onTextChange(text) }
    value={this.state.phoneNum}
    textContentType='telephoneNumber' 
    dataDetectorTypes='phoneNumber' 
    keyboardType='phone-pad' 
    maxLength={14}
/>
                        If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With