Tuesday, January 5, 2016

Disabling autocomplete in an OAF page

I have come across a question in OTN forum where a user asked to secure the credit card number entry in the Message text field of OAF.
Basically the user was looking for an option to turn off the Auto-Complete of the input field.
He cannot make the field as a Password field, because after data entry the number has to be legible to the user to confirm back with the customer.

Here is the solution given :-

If you have only one field in your page where you want to turn off the Auto complete, you can use the below.

OAMessageTextInputBean textInBean = (OAMessageTextInputBean)webBean.findIndexedChildRecursive("item1");
textInBean.setNoAutoComplete(true);


If you want to turn off the Auto complete for whole page, you can use the below code.

pageContext.putJavaScriptFunction("disableAutoComplete","function disableAutoComplete() { document.DefaultFormName.autocomplete='off';}");
OABodyBean bodyBean = (OABodyBean) pageContext.getRootWebBean();
bodyBean.setOnLoad("disableAutoComplete();");

1 comment:

  1. can you please provide JavaScript for OAF how to restricted Data for Numbers. Means MessageTextBox should accept only Numbers.

    ReplyDelete