I want to validate column by Type of employee.

Type of Employee: - Contact - Full Time

I want to validate a column for "Hire Date"(Type: Date) by "Employee Type" column.

I want the date to Null/Blank/Not selectable if "Employee Type" column is Contact. The option must be available only if the "Employee Type" column is Full Time.

I tried =IF([Employee Type]="Contract Employee", "Null") not worked.

Please assist

2 Answers 2


Yes it is possible using Javascript.
Please try the below format.

Put it in the JS file and add this code to the List's "New/Edit" forms using "Content Editor Web Part".

$(document).ready(function() {


function decideFunc(){

if($('select[id*="EmployeeType"] option:selected').val()!="Contact")
}//decideFunc ends
function hideColumn(){


$('input[id*="HireDate"]').val("");//clear the value while hide

}//hideColumn ends
function showColumn(){


if(!$('input[id*="HireDate"]' ).val().trim().length){

}//showColumn ends


did You consider using JSLink? this is a kind of Javascript attached to a column which will be 'visible' in all forms (list view, edit form, add from, display form) where the column is present.

  • You can add JSLink to column Via Powershell

Add-PSSnapin "Microsoft.SharePoint.PowerShell"
$web = Get-SPWeb "url" 
$list = $web.Lists["listName"];
$field = $list.Fields.GetField("fieldName");
$field.JSLink = "/_layouts/15/examplefile.js" 
  • or via c# which will be executed on feature active (very similar code to powershell)

please be aware that the JSlink may be stored under _layouts, or _catalogs or style library like

~sitecollection/Style Library/JSFiles/File.js

other referent types are

  • ~site – reference to the current SharePoint site (or “Web”)
  • ~sitecollection – reference to the current SharePoint site collection (or “Site”)
  • ~layouts – version specific reference to the web application Layouts folder (so it will automatically swap out /_layouts/14 or /_layouts/15 for you)
  • ~sitecollectionlayouts – reference to the layouts folder in the current site collection (e.g. /sites/team/_layouts/15)
  • ~sitelayouts – reference to the layouts folder in the current site (e.g. /sites/teams/subsite/_layouts/15)

then in this JSLink in on edit form You could add custom Javascript logic to make field readonly based on value from other column. The code should look like:

(function () {
    'use strict';

    var ctx = {};

    function init() {
        ctx.Templates = {};
        ctx.Templates.Fields = {
            'fieldName': {
                'EditForm': ReadOnly

    function ReadOnly(ctx) {
            var val = ctx.CurrentFieldValue;
            return "" + val + "";



I hope this will help :)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.