Im working on a simple app that acts as a webview. I need to disable auto complete and several other keyboard functions on anything loaded in the webview. I know how to disable autocomplete per UITextInput in a normal view controller but I don't know weather you can disable autocomplete globally on a webview?
I looked at the documentation for UITextInputTraits Here but could not seem to make anything work.
A final resort would be to disable autocomplete in the HTML tags but that would require a lot of work on the back end.
Is there a way to disable autocomplete globally for the app?
Thanks in advance.
I don't think there is a way to do this with iOS code. But, i might be wrong.
You can try running the below JS in the webview every time you load the web page
var textFields = document.getElementsByTagName('input');
if (textFields) {
var i;
for( i = 0; i < textFields.length; i++) {
var txtField = textFields[i];
if(txtField) {
txtField.setAttribute('autocomplete','off');
txtField.setAttribute('autocorrect','off');
txtField.setAttribute('autocapitalize','off');
txtField.setAttribute('spellcheck','false');
}
}
}
In my opinion, this should do the job without you having to do the changes in the server :)
Would be interested to know if this worked for you
I have searched alot for this issue. If you want to totally disable it, then you have to use <textarea>
instead of <div contenteditable="true">
and load it in UIWebview
. Try the below code:
<textarea id="content" spellcheck="false" autocorrect="off" autocomplete="off"></textarea>
By using this code, Predictive text and autocomplete both will get off.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With