How to set focus on mandatory fields if they are not filled?

GV Saranesh Kum
Kilo Guru

Hi all,

 

I observed, if mandatory fields are not filled and we try to submit the form, it gives the prompt window, stating 'the below are fields are mandatory: fieldname1, fieldname2..". Once we click OK, it sets the focus (cursor) on the unfilled mandatory field. This functionality works only if the field appear on the form, if the field is in section, it doesn't. Any suggestion how to achieve it.

 

Also as mentioned fieldname1, field name2 on the prompt message, they do not follow any order (i am expecting they should be in the order they were placed on the form).

 

kindly help.

 

Regards,

Saranesh.

10 REPLIES 10

Hi Marcelo,



Thanks for the info, this is interesting. Could you please let me know what is the name of original function this mandatory functionality uses, i hope this should be script inclue. I tried searching it, but no luck.



To my wonder, i dint find the message "The following mandatory fields are not filled in" in the messages table too. could you help me on this.



Regards,


Saranesh.


Unfortunately this kind of script is not accessible for mortals like us   SNOW are the only ones that can change this kind of functions. In order to find it, you have to use the developer tools on your browser (I pasted the original name),



Thanks,


I dint know this . Thank you.



Any inputs on my second question, in regards to order of displaying field names on prompt window.



Thanks,


Saranesh.


Bhavesh Jain1
Giga Guru

More info : GlideForm (g form) - ServiceNow Wiki


flash


void flash(widgetName, color, count)
Flashes the specified color the specified number of times in the field. Used to draw attention to a particular field.
Parameters:
widgetName - specifies the field with <table name>.<fieldname>.
color - RGB color or acceptable CSS color like "blue" or "tomato."
count - integer that determines how long the label will flash.
  • use 2 for a 1-second flash
  • use 0 for a 2-second flash
  • use -2 for a 3-second flash
  • use -4 for a 4-second flash
Returns:
void
Example:
g_form.flash("incident.number", "#FFFACD", 0);

Sanjeev Kumar1
Kilo Sage

Hi,



Use it as per your req.



if(g_form.getValue('fieldName') != ""){


                   


                                g_form.getControl('fieldName').focus();


                              return false;


           


              }