Often times you want to block a user from saving a form if a certain field value is not in line with what you expect. Whether this is a drop-down selection, or a text field or date, this field is not a required field.

JS to the rescue.

The piece of code looks as follows:

function ValidateFieldSelection(ExecutionObj)

{

// do all you data validation here

// if condition not met

ExecutionObj.getEventArgs().preventDefault();

}

In order for this to run properly, do not forget to select “Pass execution context as first parameter” when pointing to you ValidateFieldSelection function.

image

And by the way, this goes on the form OnSave event handler. Feel free to add an alert also, so the system user knows what’s happening.

Enjoy!

Advertisements