Skip to Main Content

APEX

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Please ask technical questions in the appropriate category. Thank you!

Validate without submiting

roger-lamMay 19 2023

Hi,

Is there a way to validate a page item without submitting it? Such as seeing if the data the user typing exists and then putting an inline message. I am not sure if I am explaining it well.

I tried to do it with dynamic action and ajax callback but itsn't working properly.

Dynamic action : key release :

apex.server.process(
"CHECK_VALUE_EXIST",
{
x01: $('#P2_NAME').val()
},
{
success: function(data) {
if (data.exists === 'TRUE') {
$('#P2_NAME_error_placeholder').html('<span class="t-Form-error">Value already exists.</span>');
} else {
$('#P2_NAME_error_placeholder').empty();
}

},
error: function(xhr, textStatus, errorThrown) {
// Handle error case
console.log("Error: " + errorThrown);
}
}
);

Ajax callback:

DECLARE
l_exists NUMBER;
BEGIN
SELECT 1
INTO l_exists
FROM table1
WHERE NAAM = :P2_NAME
FETCH FIRST 1 ROWS ONLY;

apex_json.open_object;
apex_json.write('exists', 'TRUE');
apex_json.close_object;
EXCEPTION
WHEN NO_DATA_FOUND THEN
apex_json.open_object;
apex_json.write('exists', 'FALSE');
apex_json.close_object;
END;

This post has been answered by Gabriel Guzman on May 19 2023
Jump to Answer
Comments
Post Details
Added on May 19 2023
2 comments
45 views