简体   繁体   中英

How to avoid user input in a field of a form in a WebView?

when I load the touch Facebook login page in the webview, I want that the email field to be set to a value and it can't be modified and to accomplish that I have inserted a JavaScript code in the webview disabling that element. All works fine until I want to click the login button because the page refreshes instead of submit the login info. I've noticed that if I don't disable the item, the login button works fine but I don't know why occurs that.

What can be the problem? I've thought another way to make it works: Whenever the user try to modify the email field ignore whatever he do, but I think this is a less proffesional way to fix that.

Regards.

You can use jQuery to bind to the keypress event for the field, then use event.which to scan for keyInput and discard all charcodes. Then the field is not disabled, it just wont accept input.

I've not be able to disable the element and send the info, so I've chosen the other way, not allow the user to input anything with the parameter readOnly instead disabled. It's easier than the Mech Software's answer, althougt thank you for your answer.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM