Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android email friendly keyboard in the input field of webview

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

like image 591
Senthil Avatar asked Nov 15 '22 03:11

Senthil


1 Answers

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...).

like image 91
Austin Hanson Avatar answered Dec 09 '22 19:12

Austin Hanson