Thursday 21 July 2016

Only Number  allowed using Javascript


 function onlyNumbers(evt) {
        var charCode;
        if (window.event)
            charCode = window.event.keyCode;   //if IE
        else
            charCode = evt.which; //if firefox
        if (charCode > 31 && (charCode < 48 || charCode > 57)) {
            alert("Please Enter Only Numeric Value");
            return false;
        }
        return true;
    }



    function ValidateText(i) {
        if (i.value.length > 0) {
            i.value = i.value.replace(/[^\d]+/g, '');
        }
    }

Call :-

<asp:TextBox ID="txtSoWValue" runat="server" onkeyup="javascript:ValidateText(this)"   onkeypress="return onlyNumbers(event);"  CssClass="left" Style="width: 28%;"></asp:TextBox>


Only Number and Character and space also allowed using Javascript

    function ValidateText(i) {
        if (i.value.length > 0) {        
            i.value = i.value.replace(/[!@#$%^&<>?:;|,/]/g, "");
        }
    }


Only Number and Character allowed using Javascript

    function ValidateText(i) {
        if (i.value.length > 0) {
            i.value = i.value.replace(/[^A-Z0-9]+/ig, '');          
        }
    }

Call :-

<asp:TextBox ID="txtWBSID" runat="server" MaxLength="25"  onkeyup="javascript:ValidateText(this)"  ></asp:TextBox>


Check the length of character

    function CheckTextLength(text, long) {
        var maxlength = new Number(long); // Change number to your max length.
        if (text.value.length > maxlength) {
            text.value = text.value.substring(0, maxlength);
            alert(" Only " + long + " Characters Allowed");
        }
    }

Call :-

<asp:TextBox ID="txtFinanceRemarks" runat="server" TextMode="MultiLine" Width="900px"  placeholder="Maximum 500 Characters" onKeyUp="CheckTextLength(this,500)" onChange="CheckTextLength(this,500)" ></asp:TextBox>                

onChange="CheckTextLength(this,500)"

Wednesday 13 July 2016

To Invisible the Active Directory User


To Invisible the Active Directory User

$cpm = Get-SPClaimProviderManager
$ad =  get-spclaimprovider -identity "AD"
$ad.Invisible = $False
$cpm.Update()

Tuesday 12 July 2016

PowerShell Command for getting the backup of WSP


PowerShell Command for getting the backup of WSP 

$FolderPath = "z:\Solutions\12July2016"
foreach ($solution in Get-SPSolution)
{
   $id = $Solution.SolutionID
   $title = $Solution.Name
   $filename = $Solution.SolutionFile.Name
   $solution.SolutionFile.SaveAs("$FolderPath\$filename")
}