Wednesday, October 21, 2015

Strict in Java Script

What is Strict: 

Strict is not statement it is a literal expression which comes in Java Script 1.8.5 library. If we are using strict in java script file than it indicate code execute under strict mode.

Example:

"use strict"
i = 10;

This code will not execute. It will give the error because we have not declare i.

"use strict"
var i =10;

It will work because we have declare the i.

Monday, June 17, 2013

Compare two time in javascript

Below is the function used to compare the two time using java scipt.


function checkTime(startTime, endTime) {
//compare two times are same or not....
if (Date.parse('17/06/2013 ' + endTime) - Date.parse('17/06/2013 ' + startTime) == 0) {
        alert('Both time cannot be same');
        return false;
    }
   else if (Date.parse('17/06/2013 ' + endTime) < Date.parse('17/06/2013 ' + startTime)) {
        alert('End time should be greater then Start time');
        return false;
    }
    return true;
}   

This function returns true if end time is greater than the start time. Otherwise it return false.
Instead of  '17/06/201' you can use any date. 


Wednesday, June 12, 2013

Time Validation in Java Script

This function validate the time format in 24 hours. 
function timeValidation(strTime) {
    if (strTime.indexOf(':') == -1 || strTime.length < 4 || strTime.length > 5) {
        return false;
    }
    var n = strTime.split(":");
    if (n.length > 2) {
        return false;
    }

    if (isNaN(n[0]) || n[0] > 23) {
        return false;
    }
    var minutePart = n[1].substring(0, 2);

    if (minutePart.length!=2 || isNaN(minutePart) || minutePart > 59) {
        return false;
    }    
    return true;

}

Wednesday, May 29, 2013

Website URL validation in Java Script

funtion WebsiteValidation(){
 var website = document.getElementById("<%=TxtWeb.ClientID %>").value.toLowerCase();
            if (website != "") {
                var websitePart = website.split(".");
                    if (websitePart.length > 2) {
                    if (websitePart[0] == "www" && websitePart[1].length > 1 && websitePart[websitePart.length - 1].length < 4 && websitePart[websitePart.length - 1].length > 1) {
                    }
                    else {
                        alert('Invalid website');
                        return false;
                    }
                }
                else {
                    alert('Invalid website');
                    return false;
                }
            }
}

Monday, May 27, 2013

Website URL validation in C#

 public bool UrlValidation(string websiteUrl)
    {                var websitePart = websiteUrl.Split('.');
                    if (websitePart.Length > 2) {
                    if (websitePart[0] == "www" && websitePart[1].Length > 1 && websitePart[websitePart.Length - 1].Length < 4 && websitePart[websitePart.Length - 1].Length > 1) {
                    return true;
                    }
                    else {
                      
                        return false;
                    }
                }
                else {
                   
                    return false;
                }
}

Friday, May 17, 2013

Remove Special Characters in SQL Server

Below is code:

Create Function [dbo].[RemoveNonAlphaCharacters]
(
   @Temp VarChar(1000)

Returns VarChar(1000) 
AS 
Begin 
 
    Declare @KeepValues as varchar(50) = '%[^a-z0-9]%' 
    While PatIndex(@KeepValues, @Temp) > 0 
        Set @Temp = Stuff(@Temp, PatIndex(@KeepValues, @Temp), 1, '') 
 
    Return @Temp 
End

Saturday, August 11, 2012

Classes Vs Structure

Below are differences between Class & Structure
1) Class are reference type but struct are vaslue type.
2) Class are comes in inheritance but struct not.
3) A struct can't be abstract but class can.
4) One can't initialized the variable in struct.
5) Fields are automatically initialized with classes.
6) A struct can't be null.

Wednesday, January 4, 2012

WCF

WCF (Window Communication Foundation) is framework for building SOA based application. WCF is just like Web Service. WCF is provides the communication between client and server. It provides better security as compared to Web Services. Interoperability is the main feature of WCF. WCF is the combination of the Web Service, MSMQ, COM+ and Remoting

Sunday, November 13, 2011

Indexes in SQL Server

Hello,

I want to learn indexes in SQL Server. I have googled lot but not find any good article. Can any one please help me