In my app I am displaying a URL on my UIWebView .This webView page also consist textfields and I want to disable the autocorrect function = off for these textfields. I have tried all the methods but all in vain.
Here is my code
[webView stringByEvaluatingJavaScriptFromString: @"var field = document.getElementsByTagName('input');"
"for(var i = 0 ;i < field.length;i++){ "
"if(field[i].type == 'text'){"
"field[i].autocorrect = 'off';"
"field[i].spellcheck='off';"
"field[i].autocomplete='off';"
"field[i].value = 'hello';"
"}"
"}"];
As you can see i tried all these function (autocorrect, autocomplete and spellcheck as off) both individually and as a combination. But nothing works.
What I discover that if you are fetching an HTML page (and that you don’t have access to its HTML source code) and you are trying to access it as above method then all will work fine like “textfield.value”, “textfield.type” etc. but the “textfield.autocorrect = ‘on’ ” (or off) does not work.
Because on clicking textfield of HTML page the keyboard of iPhone comes and you cant take object of HTML textfield to Objective C textfield. Hence the two options to solve this are:
Either make autocorrection as off from iPhone “Setting” menu .
Or ask who have access to this HTML page source code to put autocorrect=”off” in between textfield HTML code (i.e. .html file)