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;