Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

88
Views
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 answers
Answer question

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 Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!