How To Disable Smart Quotes For Textarea Fields In The Browser?
I have a application that runs in the browser that compares strings. String compares with quotes fail using iOS11 because it is defaulting to smart quotes being on. can’t does no
Solution 1:
The simplest way is to pass spellcheck="false"
to the input element. This is based on how WebKit works: https://github.com/WebKit/webkit/blob/master/Source/WebKit/UIProcess/ios/WKContentViewInteraction.mm#L4852
Solution 2:
I ended up using the document.execCommand
on the keypress event. This solution also works for contenteditable divs.
function checkInput(e) {
if ((e.which == 39) || (e.which == 8216) || (e.which == 8217)) {
e.preventDefault();
document.execCommand('insertText', 0, "'");
}
}
var el = document.getElementById('txtIn');
el.addEventListener('keypress', checkInput, false);
Post a Comment for "How To Disable Smart Quotes For Textarea Fields In The Browser?"