Assume that there is a requirement to set a minimum length for a field and we need to convey the error to the user by changing the border color. It will be useful when we are using Password kind of fields on the page. Here we are going to see how to set a minimum length for a field and if it is less than the minimum length how we can convey it to the user.

Technologies and Tools Used

The following technology has been used to achieve dynamic height adjustment for text area field.

  • Java Script
  • Oracle Apex 19

Steps to Follow

Following steps explains in detail,

Step 1: Create a region and select region type as Static Content.

Step 2: Then, create a field (Page Item), for this item we are going to add minimum length check.

It could be text field, text area, password etc.

Step 3: Now on the same page, navigate to “Function and Global Variable Declaration” under JavaScript in the page properties and add the code given below,

function min_length(element,x) {

if (element.value.length < x ){

element.style.border = “thick solid red”;

}

else{

element.style.border = “black”;

}

}

 

Step 4: Then add the code given below in the “Custom Attributes” section available in the page item property

onfocusout=” min_length(this,8)”

Here we can pass the minimum length required for that particular page item as a parameter for the function. For example, I have passed 8 here. So if the length of the page item value is less than 8 then the border of the field will turn red on focus out.

 

Output

Here we can see the border is turn red because the of the field is less than 8.

But if you have entered more than the minimum size it will display normal

Recent Posts

Start typing and press Enter to search