Introduction:
This post talks about how to restrict adding more than one blank row in Tabular form using JavaScript in Oracle Apex.
Procedure:
- Create a Tabular form region.
- After creating Tabular form, navigate to Add Row button and change the action to “Defined by Dynamic Action”.
- Then create a Dynamic action as following,
Event : Click
Type : Button
Button : Add Row
Action : Execute JavaScript Code
Code :
var i = 1, count = 0, c;
while (i != 0) {
b = “000” + i;
//alert(b);
b = pad(i, 4); // calls function pad and pads 4 zeros
a = $x(“f02_” + b).value; // checking value for the mandatory column
if (typeof a === “undefined”) {
i = 0;
} else {
c = a.trim();
if (c.length == 0) {
count = count + 1; }
i = i + 1;
}}
if (count == 0) {
javascript: apex.widget.tabular.addRow(); // Add New Row
}else {
alert(“Blank row already exists. Hence you cannot add a row”);
}
function pad(n, width, z) {
z = z || ‘0’;
n = n + ”;
return n.length >= width ? n : new Array(width – n.length + 1).join(z) + n;
}
This post uses the JavaScript to make work of restricting user to add more than one blank row in Tabular form.
Call To Action:
For Oracle apex development and customization please do visit our company website https://doyensys.com/
Conclusion:
By adding this functionality, we can lead the user to prevent from the unwanted confusion.