How do I add validation to text area in oracle apex - oracle-apex

I am feed up with this Oracle APEX application , their is no proper videos or documentation
I have a Text area field and button
On button click I have written a PL/SQL code to send mail
Is their any way I can populate error / success message on screen
If text area is empty does not have any data then display error message on screen as Text area field is empty
My code :
BEGIN
if (:textarea1 is not null ) then
APEX_MAIL.SEND(p_from => 'alice#example.com',
p_to => 'bob#example.com',
p_subj => 'Email from Oracle Autonomous Database',
p_body => 'Sent using APEX_MAIL');
else
--popup error message on my screen -> `textarea` filed cannot be empty
end if;
END;
The following package of ADD_ERROR.ADD_ERROR does not exist at my end

If text area is empty does not have any data then display error message on screen
You don't need your own validation for that; just set that item's Value required property ON.
Additionally, you can even set process' Server side condition to
When button pressed: pick the button you use to send an e-mail
Type: Item is not null; pick the text area item
You commented that it isn't working. Well, it is. If it doesn't for you, then you did something wrong (although, I can't imagine what would that be, regarding the fact that it is just one property you had to set).
So: if I leave the text area empty and push the button, error message is here:
As of a video with demonstration: I don't have any. Google for it, if you desperately need it.

Related

Attachments moved away from Item after validation and before submit process in Apex

I have multiple File Browser Item fields on one page of Application in Oracle Apex.
What happens: When I miss any Item for which validation error fires, I want to hold that file to the browser but I usually loose it if I get that validation error. Is there a solution for the same like other Items fields hold previous value except File Browser Item field. Please see below ss:
Anshul,
APEX 4.2 is very old and no longer supported. A later (or preferably latest) version of APEX will behave differently as Dan explained above.
Can you import your application into apex.oracle.com (which is running APEX 20.1) and you will probably see better results. Based on this you can hopefully use it as justification to upgrade your environment.
Regards,
David
Go to your page-level attributes and a function like the following in the Function and Global Variable Declaration:
function validateItems(request) {
var $file1 = $('#P68_FILE_1');
var $file2 = $('#P68_FILE_2');
var errorsFound = false;
if ($file1.val() === '') {
errorsFound = true;
// Show item in error state
}
if ($file2.val() === '') {
errorsFound = true;
// Show item in error state
}
if (!errorsFound) {
// I think doSubmit was the name of the function back then. If not, try apex.submit
doSubmit(request);
} else {
// Show error message at top of page, I'll use a generic alert for now
alert('You must select a file for each file selector.');
}
}
Then, right-click the Create button and select Create a Dynamic Action. Set the name of the Dynamic Action to Create button clicked.
For the Action, set Type to Execute JavaScript Code. Enter the following JS in code:
validateItems('CREATE');
Finally, ensure that Fire on Initialization is disabled.
Repeat the process for the Save button, but change the request value passed to validateItems to SAVE.

Oracle APEX - how i can change translate action menu language (interactive grid and report)

I'm trying to change the language of default UI elements language in my APEX application to Arabic language :
i change the button (excepted interactive button) and column header language using XLIFF file , but i can't change action menu language , how i can do that if it possible.
You have to create new "messages":
Try to find message id:
select *
from APEX_APPLICATION_TRANSLATIONS
where WORKSPACE = 'INTERNAL'
and message_text = 'Subscription';
Copy TRANSLATABLE_MESSAGE field value (e.g. APEX.IG.SUBSCRIPTION or APEXIR_SUBSCRIPTION) and remember IS_JS_MESSAGE value
Go to Shared Components -> Globalization -> Text Messages -> Create Text message
Put id id name field (APEX.IG.SUBSCRIPTION)
Select your language
Fill "Text"
Select the same value as already exists in field IS_JS_MESSAGE
Your application language must me the same with this new message.

Unchecking checkbox in oracle apex

Created an report with checkbox using apex_item and when checked more than one check box i will display alert message "not to check more than one checkbox with ok button " after clicking ok it should be unchecked . please find my JavaScript code that displays alert message
if($("input[type=checkbox]:checked").length > 1)
{
var msg = alert('You are not allowed to select more than one employee');
}
It's best to use the APEX JavaScript APIs for this type of thing. You can find them here: https://apex.oracle.com/jsapi
If you're getting started with JavaScript and APEX, you may find these slides useful: https://www.slideshare.net/DanielMcGhan/getting-started-with-javascript-for-apex-developers
Here's a solution that should work for you (just change the name of the item to match yours):
var cbItem = apex.item('P1_CHECKBOX');
if (cbItem.getValue().length > 1) {
alert('You are not allowed to select more than one employee');
cbItem.setValue(); // Passing nothing to clear the value
}

How can I clear the focus from a desensitized GtkWidget - GtkSpinButton with property sensitive = false

Background: I have a few tabs set up in my GtkNotebook, and when certain conditions are met on the main tab, then input fields in the 'test signals' tab are accordingly disabled.
When the input inside a GtkSpinButton is highlighted on the 'test signals' tab and the GtkSpinButton's property sensitive is set to false, the text within the GtkSpinButton remains highlighted. Because sometimes there are no other editable fields on this tab, the text remains highlighted until another widget has its property sensitive set to true.
This just looks sloppy to me, so I would like to stop this behavior and have the widgets that are set to sensitive = false all cleared of focus or highlighting. Any idea how to un-highlight the text within the GtkSpinButton, maybe before setting sensitive = false?
To get rid of a selection you can use the gtk_editable_select_region() function. This is a method on GtkEditable, an interface that both GtkEntry and GtkSpinButton satisfy. You can convert either of these to GtkEditable with GTK_EDITABLE(). For example:
gtk_editable_select_region(GTK_EDITABLE(spinbutton), 0, 0);

Validating an Edit Control's text while the user types MFC

Question/Problem: I have an edit control (text box) that the user enters a username into. I am attempting to compare the username entered to the ones listed in my List Control. If the username given matches, my button's text should change from Create User to Update User.
My problem is in finding the correct event/time to compare the strings, without creating an infinite loop.
What I have tried: I have tried using the edit control events EN_CHANGE and EN_UPDATE. Both of these events cause stack-overflow exception or an infinite loop. I thought that one of these events would be called every time something is typed or the backspace was used within my edit control.
In my EN_CHANGE / EN_UPDATE event, I compare the username strings and set the button's text. With either event, it is called infinite times:
void Users::OnEnUpdateLoginName() //EN_UPDATE Event
{
bool match = false;
//Compare the edit control text with each List Control text.
for(int i = 0; i<m_UserList.GetItemCount(); i++)
{
if(strcmp(m_UserList.GetItemText(i,0),m_loginName)==0)
match = true;
}
//If the usernames match, change the button's text to "Update User"
if(match)
{
CWnd *currentSelection = GetDlgItem(TXTC_LOGIN_NAME);
currentSelection->SetWindowTextA("Update User");
}
else
{
CWnd *currentSelection = GetDlgItem(TXTC_LOGIN_NAME);
currentSelection->SetWindowTextA("Create User");
}
}
.
If the text in red matches, change the text of the button highlighted in blue.
Should I be using a different event to validate the string in real-time as the user types?
My code had two issues. I needed to use UpdateData, so that data for all my dialog controls would be current. I also was updating the wrong variables. Thanks #rrirower