How to Validate Email Entry In A Column Using Column Validation In SharePoint

So you have created a column to collect email addresses in a SharePoint list and you want to validate that only properly formed email addresses are entered by users?
This is what you have to do;

·       Go to the “List Setting”

·       Under “List Setting” go to the “Columns” section and click on the column you will like to validate

·       On the column page locate the “Column Validation” section expand it if it is collapsed and paste the following into the formula text box

=(LEN(LEFT([Employee Email],FIND("@",[Employee Email])-1))>0)+(LEN(RIGHT([Employee Email],LEN([Employee Email])-FIND(".",[Employee Email],FIND("@",[Employee Email]))))>0)+(LEN(MID([Employee Email],FIND("@",[Employee Email])+1,FIND(".",[Employee Email],FIND("@",[Employee Email]))-FIND("@",[Employee Email])-1))>0)+(ISERROR(FIND(" ",[Employee Email]))=TRUE)=4



·       And enter the appropriate validation error message into the “User Message” text box

·       That’s it your column is validated!!!
 

How To Extract Day, Month, or Year From A Date/DatePicker In InfoPath Forms For SharePoint

In InfoPath, under Fields, Right Click on the single line of text field and choose Field Properties.
Under the Default Value section click the “fx” button beside the blank field.

To extract the day number of a date, use
number(substring([Date Picker Field], 9, 2))

To extract the month number of a date, use
number(substring([Date Picker Field], 6, 2))

To extract the year number of a date, use
number(substring([Date Picker Field], 1, 4))


Where [Date Picker Field] represents a date picker control or the function of today() to pull any of those from today’s date.

How To Use Google Search Like A Boss

The Google search engine is more intelligent than most of us know only if we could use the right keywords and syntax when we search. This infographic shows you how to use Google search like a pro

How To Clear The Values Of All Input Controls On An ASP.NET Web Form Page At A Go

So one of the most boring things you have to do as an asp.net web developer is to have to clear all values on input control after submission of the form . Usually i would have to clear the values of each control one after the other till there was no control to be cleared (trust me this is boring). I then thought there had to be an easier way to achieve this so i got my hands dirty and came up with a way to achieve this. Without further ado see the how in the code snippets below

THE BORING WAY
//Clearing all the controls one after the other
    private void ClearControls()
    {
        txtName.Text= string.Empty;
        txtAddress.Text = string.Empty;
        txtEmail.Text = string.Empty;
        txtTelephone.Text = string.Empty;
        txtFax.Text = string.Empty;
        txtRemark.Text = string.Empty;
    }

THE SMART WAY (C#.NET)
//Loop through all the input controls on the page and empty them
    public static void ClearControls(Control control)
    {
        try
        {
            foreach (Control ctrl in control.Controls)
            {
                if (ctrl is TextBox)
                {
                    (ctrl as TextBox).Text = string.Empty;
                }
                else if (ctrl is DropDownList)
                {
                    (ctrl as DropDownList).SelectedIndex = 0;
                }
                else if (ctrl is CheckBox)
                {
                    (ctrl as CheckBox).Checked = false;
                }
                ClearControls(ctrl);
            }

        }
        catch (Exception ex)
        {
        }
    }

THE SMART WAY (VB.NET)
'Loop through all the input controls on the page and empty them
    Public Shared Sub ClearControls(control As Control)
        Try
            For Each ctrl As Control In control.Controls
                If TypeOf ctrl Is TextBox Then
                    TryCast(ctrl, TextBox).Text = String.Empty
                ElseIf TypeOf ctrl Is DropDownList Then
                    TryCast(ctrl, DropDownList).SelectedIndex = 0
                ElseIf TypeOf ctrl Is CheckBox Then
                    TryCast(ctrl, CheckBox).Checked = False
                End If
                ClearControls(ctrl)
            Next
        Catch ex As Exception

        End Try
    End Sub


USAGE
//Call the method and pass Page as the parameter
ClearControls(Page);

SUMMARY
The method above takes a control as parameter loops through the control looking for text boxes, combo boxes and check box and setting them to their default values. You will notice that the method was called within itself this is called a recursive (to know more about recursive visit this post) this makes sure that if there are container controls like asp panel or content place holders it steps into the controls and clear input controls in the container.

How To Manipulate Cookies With JQuery

When developing web applications you sometimes need to keep track of some things on the clients computer cookies can help you achieve that. A Cookie is a small text based file given to you by a visited website that helps identify you to that site. Cookies are used to maintain state information as you navigate different pages on a Web site or return to the Web site at a later time.

In this post i will show you how to create, retrieve, delete and generally how to manipulate a cookie using jquery. To do this there is already a jquery plugin (jquery cookie) that greatly simplifies this process. Download the plugin and reference it after you have referenced your jquery because the plugin requires jquery to work.

Now we can get our hands dirty and play with cookies

CREATING (SETTING) A COOKIE

  • Create a session cookie
    $.cookie('name', 'john doe');
    //creates a cookie called name and assigns the value 'john doe' to it
    

  • Create a session cookie that expires in day(s)
    $.cookie('name', 'john doe',{ expires: 5 });
    //creates a cookie called name and assigns the value 'john doe' to it 
    //and the cookie expires in 5 days
    

  • Create a session cookie that expires in minutes(s)
    //Getting the current date and time
    var tenMinsAhead = new Date();
    
    //Converting 10mins to milliseconds
    var minOffset = 10*60*1000;
    
    //adding 10mins to current time
    tenMinsAhead.setTime(tenMinsAhead.getTime() + tenMinsAhead);
    
    $.cookie('name', 'john doe',{ expires: tenMinsAhead });
    //creates a cookie called name and assigns the value 'john doe' to it 
    //then sets the cookie expires 10 minutes to the time it was created
    

RETRIEVING (GETTING) A COOKIE

  • Retrieve a session cookie
    $.cookie('name', 'John Doe');
    $.cookie('age', '150');
    $.cookie('location', 'Lagos Nigeria');
    
    //Retrieve a particular session cookie
    $.cookie('name');//=> John Doe
    
    //Retrieve all available session cookies
    $.cookie();//=> { "name": "John Doe","age": "150","location", "Lagos Nigeria" } 

DELETING A COOKIE

  • Delete a session cookie
    // Returns true when cookie was successfully deleted, otherwise false
    $.removeCookie('name'); // => true
    $.removeCookie('nothing'); // => false