Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

89
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda