Apex Oracle Javascript validation - oracle-apex

I am trying to Incorporate a javascript validation on an application in apex.
Basically, what should happen is that the validation should run if i click on a textfield or another Item type. I want to the validation to runs without me having to click on a submit or save button.
For an example if I was filling out a form, I want to validation straight after the user click from "FirstName" field to "LastName" and each individual field will have it own validation.
The reason why I want to do this is because I have an application which takes about 15-30 minutes to fill out and sometimes after you spend all those mins filling it out and click on save or create. you get a long list of validation errors. To avoid this I want to use javascript/Ajax to do a validation which validate individual fields straight after you click from one field to another.
I have a feeling it can be done but i dont know how. Please point me on the right direction.
EDITED
for an example I have this validations
begin
if length(:p1_subject) >3 then
return false;
else
return true;
end if;
end;
This validation will only run when i click on the create button but I want it to work everything you click off and on the p1_subject field.
Hope I am making sense.
Thank you very much.

Related

Oracle apex form doesent INSERT/UPDATE or Create entry in database

Hi everyone so I have a problem with Oracle Apex, I created a master-detail with a from and everything worked fine. Then I created another page within the same app but nothing connected to the page mentioned before, and now nothing on the first page works. When I try to create an entry the form opens I can type anything in and when I click "create" the form closes and nothing happens. Nothing is inserted into the database, edit also doesn't work as well ass deletes everything looks perfect till the form closes, the region refreshes but nothing actually happens.
No error shows up in the app or in the console/debugger
I checked the form processes and the DML is there.
Tried to manually set value in SQL Workshop and that works, I'm able to manually insert rows but not through the form.
Please help this is for my final project and I need this to work.
Thank you in advance!
Edit: 4) Also saw that no button works on the form. I have a combination of form + interactive grid and the grid usualy has like a page navigation buttons for previous/ next and those dont work aswell. So maybe i try deleting and re creating all the buttons?
EDIT2: Managed to fix it, and found that I was somehow missing the Close Dialog process in my form. Added it and now everything works!
Close dialog process in the form page was missing, recreated it from a different form, and now everything works!

Allow to check only one checkbox in Oracle apex

I created classic report with check boxes using apex_item.checkbox .I want to know how to allow to check only checkbox.That is if i click more than checkbox alert message should display.Please help me out
Thanks in advance.
If you want to do this via dynamic actions then you will want do a dynamic action on event Change, Selection Type jQuery Selector and the jQuery Selector being input[name = "something"]
This something you can figure out by running the page as is, and if you click F12 on your keyboard, the console will open. Then select the element that is your checkbox and find its name and this should be your "something". Play around with this to make it work(set the DA to run an alert or something to see when its triggered).
Then perhaps have a page item that is filled when this DA runs, and then if the page item is already filled and the DA runs, throw up an error saying you cant do this.
Or if you want to clear the previously checked box, you could save the name of currently checked box in the page item. And have the DA do a javascript function that clears the value in the field in the page item.
Basically have the DA get the name of the checked box from the item where you store it, and do some dynamic javascript. When I needed to do something similair I created a var in javascript that was formed like $s(" + checked_box + ", ""); assembling this with concat. And then do an eval(this_concacted_instruction).
I hope my ramblings guide you to a solution. I remember the first time I was working with this stuff I took a week to get one page sorted(although it was a bit more difficult than your problem), but it felt sooo good when I got it done. So keep on trying.
GLHF

How to fill dynamic form fields using capybara

I have a form that contains a select box and a text field.
The text field is displayed dynamically based on the selectbox selection. If the value of selectbox is "Yes", then the text field will be displayed and vice versa.
I am running an rspec test and filled the select box value with "Yes"
select 'Yes', from: 'property[have_water_bills]'
Now i want to fill a value on the text field
fill_in 'property[irrigation_cycle_count]', with: 5
But i am getting the following error.
Capybara::ElementNotFound:
Unable to find field "property[irrigation_cycle_count]"
That is, capybara cannot find the dynamic element. Does anyone know how to fix this?
Poltergeist doesn't gemerate a click event when choosing an item from a select. It generates a focus on the option, change on the select, blur on the option. It is more like if a user selected the option with keyboard instead of using a mouse. You probably should be doing the logic to display your text field on the change event anyway so that it works if people use a mouse or a keyboard to navigate around your page. It also makes more sense to run your show/hide logic on the change event because that's what you actually care about, not clicks.
Finally got this to work using the following piece of code
page.execute_script("$('#have_water_bills').val('true').trigger('click')")

Django multi-select widget. Add arbitrary select components

i would like to make a widget that lets the user select a value from a drop-down list and then add new drop-down lists with values filtered based on the previous selections. I don't know where to start from....
If the amount of drop-downs is finite and determinable by the time you develop the software (e.g. selecting country->city->street) I would suggest to:
add all the extra dropdowns (without data yet) to your form, make sure they are hidden
use jqueryui to un-hide and populate the dropdowns as needed using ajax
Don't forget to disable/hide the whole form by default and only show it if JS is enabled in browser.
Also, you will of course need another view, with which only ajax speaks.
Here for you to catch the idea how the stuff should work. Sorry don't know if they have anything more similar. But: user selects something -> jquery requests data for the next dropdown -> jquery displays next populated dropdown.

displaying a php contact form conditional upon cookie

I have php contact form with a submit button, what i would like to do is display this form conditional upon a cookie.
For example, if websitecookie =1, then display the contact form, or else display a message such as "form has already been completed." or even display a page with just one image in the center such as image.png and nothing else.
The solution is something along the lines of:
if (isset($_COOKIE['websitecookie'])
{
die('You may only submit this form once per session!');
}
But im getting stuck as to how i can add the contact form and image.png values within the condition. Thanks.
To me, it seems you're trying to avoid spam.
If that's the case, you should know that spam is mostly generated by bots looking for forms open to the public, without any form of validation. Cookies won't stop them!
To prevent this, you could insert a captcha.
http://nl.wikipedia.org/wiki/Captcha
In all other cases, the best options seems to require visitors to login so you can track their last 'submit' through a timestamp in the database.