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

86
Visualizações
How to escape apostrophe successfully in jQuery on iPhone that has Smart Punctuation

I haven't been able to successfully escape Apostrophe on iPhone. After some research, it seems the Smart Punctation feature is causing some issues here. I've tried everything I can find and nothing has worked.

A user is entering text into a field and I verify if this text is correct. Here is my jQuery code. The valid Text is EMPORER'S EYE or Emporer's Eye, but neither ever comes up as valid on iPhone.

$("#actionButton").click(function() {
var seats = $("#number2").val();
var apostrophe = '\u0027';
var error = null;


if ((seats === "EMPORER\'S EYE") || (seats === 'Emporer\'s Eye')) {
 $("#message").fadeIn();
   $("#draggable").fadeOut();
  $("#draggable2").fadeOut();
} else {
  $("#messageWrong").fadeIn().delay(2500).fadeOut();
     $("#draggable").fadeOut().delay(2500).fadeIn();
  $("#draggable2").fadeOut().delay(2500).fadeIn();
}


// If you really need setflag:
var setflag = error != null;
});

Here is a codepen I have of the entire function and process I'm trying to put together. https://codepen.io/MaxwellR/pen/BaYGPJL

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

0

In order to make user experience less frustrating, I would skip on checking the special characters, as this is a slippery slope.

You can convert both input and expected value to certain format that allows some degree of liberty in how people spell things. Consider this example:

const sanitizeString = string => string
    .trim() // remove surrounding whitespace
    .toLowerCase() // ignore the case
    .replaceAll(/[^\p{L}\s]/gu, '') // cut out all special characters
    .replaceAll(/\s+/g, ' '); // convert any consecutive whitespace to a space

This can be a good balance between being correct and having some freedom to spell things differently.

const string = 'Emporer\'s Eye';
const sanitizedString = sanitizeString(string);
// sanitizedString is now "emporers eye"

In your case, you could have a single value inside the condition and it would work:

if (sanitizedString(seats) === sanitizedString('Emporer\'s Eye')) {
    // some magic
}
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