Question: I have created a custom newform.aspx by cloning the form generated by SharePoint Designer and added it to a VS2010 project. Everything seems to be working fine like setting the value etc... but I couldn't figure out how to set the `Required` property of a field.

Based on a certain condition I would like to set the required property of a field to true or false.

I am accessing the controls using `CompositeField` and `BaseFieldControl` but they dont seem to give a handle to set required property value.

Any pointers are greatly appreciated.

Answer: 
Its a self calling function, that invokes its self as the script finishes loading. You can call it without arguments, or you can add arguments to it such as `window` or `document`.

You use it in a way that jQuery use it:

```
(function( window, undefined ) {
    // jQuery code
})(window);

```

An (almost) alternative syntax to do the same thing:

```
! function( window, undefined ){
    // some code…
}(window);

```

Read more at: <http://sarfraznawaz.wordpress.com/2012/01/26/javascript-self-invoking-functions/>
Self invoking function, basically it calls itself stright away.

Used normally to pass in a variable like jQuery to insure that `$` is truly the jQuery object!

```
(function($){
    // $ now is equal to jQuery
})(jQuery);

```