question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Mixed mask with numbers and letters not working

See original GitHub issue

Hello everyone.

I’m trying to create a TextInputMask with the following mask

[AAA]-[0000]

(this is the pattern for vehicles license plate here in brazil)

But when i type the input field behaves like this:

Here is my code:

<TextInputMask
    keyboardType='default'
    refInput={ref => { this.TEXT_INPUT_REF = ref; }}
    returnKeyType='go'
    placeholder={Texts.Placeholders.LICENSE_PLATE} /* AAA-0000 */
    style={styles.inputField}
    onChangeText={text => this.props.writeVehicle(text)}
    value={this.props.vehicle}
    autoCapitalize='characters'
    mask={Texts.Masks.LICENSE_PLATE} /* [AAA]-[0000] */
/>

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Reactions:6
  • Comments:8

github_iconTop GitHub Comments

1reaction
BanidAzincommented, Oct 26, 2018

Thanks @sterfanno , but still I am getting an error, the value is duplicating

import React, { Component } from 'react';
import { TextInputMask } from 'react-native-masked-text';
import { Item, Form, Label, Text, } from 'native-base';

class AddScreen extends Component {
    constructor(props) {
        super(props);
    this.state = {
        vehiclenumber: '',
    };
}
  componentDidMount() {
      this.input.setNativeProps({
          text: this.state.vehiclenumber
      });
  }
    onVehicleNumberChange(text) {
        this.setState({
            vehiclenumber: text,
            error: '',
        });
        this.componentDidMount();
    }
render() {
        return (
         <View style={styles.containerStyle}>
           <Form style={styles.formStyle}>
              <Item
                 stackedLabel
                 style={styles.itemStyle}
              >
                 <Label
                    style={styles.labelStyle}
                 >
                     Vehicle Number
              </Label>
              <TextInputMask
                refInput={ref => { this.input = ref; }}
                style={{ 
                    color: 'white',
                    flex: 1,
                    flexDirection: 'row', 
                    width: '100%', 
                    paddingLeft: 10,
                    fontSize: 18, 
                }}
                type={'custom'}
                options={{ mask: 'AA99A-9999' }}
                onChangeText={this.onVehicleNumberChange.bind(this)}
              />
              </Item>
        </Form>
     </View>
    );
  }
}

ezgif com-video-to-gif

Works fine on emulator, but this is the behaviour in real devices, don’t know what causing this, thanks in advance

0reactions
sterfannocommented, Oct 11, 2018

import {TextInputMask} from 'react-native-masked-text'

<TextInputMask                                    
   autoCapitalize="characters"
   type={'custom'}
   options={{mask: 'AAA-9999'}}
   value={}
   onChangeText={} />
Read more comments on GitHub >

github_iconTop Results From Across the Web

Mixed mask with numbers and letters not working #40
Hello everyone. I'm trying to create a TextInputMask with the following mask [AAA]-[0000] (this is the pattern for vehicles license plate ...
Read more >
Control data entry formats with input masks - Microsoft Support
A combination of mandatory letters and characters, all uppercase. Use this type of input mask, for example, to help users enter part numbers...
Read more >
Input mask jquery : letter or number - Stack Overflow
How to get the format where user can input letter or number,. A = Letter, 9 = number. I need a mask like...
Read more >
How to Use an Input Mask in Microsoft Access ... - YouTube
We will create input masks for telephone numbers, ZIP cod... ... I recently wanted to make a report showing customers by area code, ......
Read more >
Introduction to Access Input Masks, Numbers, Letters, Capital ...
An Introduction to Input Masks. Numbers 0 9Letters L ?Capital. Small Case!
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found