check box should be checked before submitting

Shweta1
Kilo Contributor

In the  case form, security check box should be mandatory before submitting.But i am able to submit without clicking on checkbox .Its not highlighting the mandatory field.

I have given UI policy still not working.It should be mandatory and visible only when Channel field is selected as Phone.

 

find_real_file.png

find_real_file.png

4 REPLIES 4

Kunal Varkhede
Tera Guru

Hi,

Use OnSubmit() client script.

 

g_form.setMandatory('security_check_complete',true);

 

Thanks,

Kunal 

Siddhnath Pande
Mega Guru

Hey Sweta

Because might be there is initial value is already assign i.e. false or uncheck.

Because the initial value is already assign to that filed. & you are validating that field should be filled which is true. That is the reason it got submitted.

So you can remove the initial value which, I tried to do I can't. however if you can do that I am sure your query will be resolve.

Another way either you can change it to drop-down list with the option of true & false or you can just validate that this filed should be clicked.

If the above suggestion helped you then please mark my answer Correct and Helpful.

Thanks and Regards:
Siddhnath Pandey

Subhojit Das
Kilo Guru

Hi Shweta,

If you want Security Check Complete as checked why don't you make it's default value as "true" because making a checkbox field mandatory is of no use as it retains true and false value. In your case form will be submitted if you check or uncheck the box. Why don't you try to show alert to user to make the field checked while submitting the form using onSubmit Client Script or use before BR, If he tries to submit the form without making the field checked, show error message and use abort action to abort the form from submission.

If I suggestions make sense then mark as Correct and Helpful.

If any assistance is needed please let me know.

 

Regards,

SUbhojit

 

 

Ankur Bawiskar
Tera Patron
Tera Patron

Hi Shweta,

that's because it is boolean field and even with a value of False it considers it as a valid value and hence you don't see the red mark

you can use onSubmit client script for this; remove UI policy

function onSubmit(){

if(g_form.getValue('channel') == 'phone'){

if(g_form.getValue('u_security_check_complete').toString() != 'true'){
g_form.addErrorMessage('Please mark the checkbox of security check complete');
return false;
}

}

}

Mark Correct if this solves your issue and also mark 👍 Helpful if you find my response worthy based on the impact.
Thanks
Ankur

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader