How can I create oracle apex server side live validation without need to submit page -


i created form customers, need validate customer name

1 - type new name item p1_cust_name. 2 - after leaving item go database , check if name exist or not.  3 - display alert or message client. 4 - prevent client navigating way item until enter valid data. 

yes, can create server side validation using dynamic action , javascript function apex.server.process.

a basic example demonstrate-

  • create page item e.g. p4_name in page
  • create page process , select execution point "ajax callback". enter image description here

in below code checking p4_item value, can write own logic validate.

begin    if :p4_name = 'himanshu'          htp.prn ('success');    else       htp.prn ('error');    end if; end; 
  • now create new dynamic action , select event "lose focus", selection type "item(s)" , in item(s) select item name.

enter image description here

  • create true action , select "execute javascript code".

in code section, implement apex.server.process below-

apex.server.process('validate_name', {    pageitems : '#p4_name' } , {    datatype : 'text', success : function(data)    {       if(data != 'success')alert(data);    } } ) 

the first argument page process name(validate_name) have create earlier, second data want submit process , third options. more details on apex.server.process

it done. refresh page , check. on validation failure alert.

you can customize js code further display error messages in more fancy way instead of showing alert.


Comments

Popular posts from this blog

node.js - Node js - Trying to send POST request, but it is not loading javascript content -

javascript - Replicate keyboard event with html button -

javascript - Web audio api 5.1 surround example not working in firefox -