10 Days Challenge–Tip #4

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!

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

Create a website or blog at WordPress.com

Up ↑

%d bloggers like this: