Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

395
Visualizações
Validate IP Address in React Native

I am looking for a way to validate ip adrress field (onChange) in my RN mobile app.

But it's taking both valid and invalid ip addresses and also number of digits in each part remains exact three.

Screenshot of App

I am using react-native-mask-input and so far I have tried this:

const ipMask = [
    [/\d/],
    [/\d/],
    [/\d/],
    '.',
    [/\d/],
    [/\d/],
    [/\d/],
    '.',
    [/\d/],
    [/\d/],
    [/\d/],
    '.',
    [/\d/],
    [/\d/],
    [/\d/],
  ];

<View style={{flexDirection: 'row'}}>
        <View style={{flex: 1, flexDirection: 'column'}}>
          <View style={{flexDirection: 'row'}}>
            <Text
              style={{
                fontFamily: 'Titillium-Semibold',
                color: Colors.grey_888888,
                fontSize: 14,
                marginLeft: 13,
              }}>
              IP Address *
            </Text>
          </View>
          <MaskInput
            value={ip}
            mask={ipMask}
            style={{
              marginLeft: 10,
              marginRight: 10,
              marginTop: 5,
              fontSize: 15,
              width: '95%',
              fontFamily: 'Titillium-Semibold',
              fontWeight: 'normal',
              paddingBottom: 0,
              height: 50,
              backgroundColor: '#FAFAFA',
              borderColor: Colors.grey_C0C0C0,
              borderWidth: 1,
              borderRadius: 5,
            }}
            onChangeText={(masked, unmasked, obfuscated) => {
              setIP(masked);
            }}
          />
          <Text
            style={{
              fontFamily: 'Titillium-Semibold',
              color: Colors.red_FF0000,
              fontSize: 11,
              marginLeft: 10,
            }}>
            {requiredMsg.ip && 'IP address is required !!!'}
          </Text>
        </View>
      </View>

Can anyone suggest me a way to validate ip address correctly?

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

Get the is-ip package from NPM. The link here can be helpful.

Then, you can simply use the functions to check. E.g:

isIP('192.168.0.1'); // returns true

You'll find more code sample in the webpage above.

EDIT: I just noticed the date of the question... :')

about 4 years ago · Juan Pablo Isaza Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda