Prevent save/update/submit if field value not valid

tommyjensen
Giga Expert

I want to validate a field for duplicate entry before saving the record.

So I would like a client script to validate the value and if the value is not valid I will display a field message (got that part) but then I want to prevent a save/submit to be performed. How can I do that?

1 ACCEPTED SOLUTION

bernyalvarado
Mega Sage

Hi Tommy,



If you're trying to do this validation from an onSubmit client script, I believe you can then return false within your script when the value is not valid and the submission will be stopped.



Thanks,


Berny


View solution in original post

8 REPLIES 8

You're welcome


This works for stopping an update, but the "Closed Complete" button will ignore the client script and update the record anyways. Any idea why?


Hi Shane, if that's happening the something could potentially be wrong with your client script. You may also want to check your browser's console to make sure that there's no errors from your or other scripts at your instance that could be affecting the execution of your client script validation.



I hope this helps!



Thanks,


Berny


Govind Kumar S1
Kilo Guru

You need to do something like this


find_real_file.png


on Name field present in sys_user_group table we have unique key Rule, whenever you try to insert duplicate value it will throw an error as shown in Image.



Thanks & regards


Govind Kumar Sharma




PS: Hit like, Helpful or Correct depending on the impact of the response.