Wednesday 6 August 2014

Show/Hide #SharePoint columns in a List based on selected values in a drop-down list:


<script language="javascript" type="text/javascript">
$(document).ready(function() {
    showhide();
   $("select[title='FieldName']").change(function() { showhide(); });

});

function showhide()
{
   alert("inside function");// just to debug script , remove while move in production
    var thisVal =  $("select[title='FieldName']").val();
    alert(thisVal);// just to debug script , remove while move in production
    if (thisVal=="Somevalue")// your condition
    {
    alert("show all");// just to debug script , remove while move in production
     $('nobr:contains("FieldName")').closest('tr').show();


}
else
      {
     alert("inside else");// just to debug script , remove while move in production
     $('nobr:contains("FieldName")').closest('tr').hide();

}
</script>

Simple #JQuery to validate any column or field value in SharePoint:



<script src="/sites/rndsite/Style%20Library/jquery-1.8.1.js" type="text/javascript">  </script>
  <script type="text/javascript">
     function PreSaveAction() {
alert('hi');// just to debug script , remove while move in production
alert($("select[title='Fieldname']").val()));
           if($("select[title='Fieldname']").val() ==' ')          {
          alert('Serial number field is Empty: Please enter some value');// just to debug script, remove while move in production
          return false;
          }
            }
    </script>

Hide Time from events in Calendar list or webpart Use below code in content edit webpart or by editing list page in SharePoint designer ...