Reputation: 523
I have a webview in which user has to type their email and password in the corresponding input fields. I want to show the email friendly keyboard when the user taps on the email field. How to do it using javascript ?
I tried using the javascript by using the following code
String emailKeyboard="document.getElementById('src').type=\"email\";";
mWebView.loadUrl("javascript:(function() { " + emailKeyboard +"})()");
also i tried by getting the element by name as
String emailKeyboard="document.getElementByName('j_username').type=\"email\";";
mWebView.loadUrl("javascript:(function() { " + emailKeyboard +"})()");
where j_username is the name of the input field. But it is not working. Any help greatly appreciated.
Thanks, Senthil.M
Upvotes: 5
Views: 1220
Reputation: 22040
Why not just set the type of the fields directly in the HTML rather than trying to add them on the fly (which causes more strain on performance anyway...).
Upvotes: 1