Tuesday, April 14, 2015

Create Function in sql

ALTER FUNCTION [dbo].[Test]
(
@user_id varchar(100)
)
RETURNS INT
AS
BEGIN
-- Declare the return variable here
DECLARE @vParaVal INT

-- Add the T-SQL statements to compute the return value here
SELECT @vParaVal = department_id from Test where [user_id] = @user_id

RETURN @vParaVal

END

remove foreign key constraint in sql


ALTER TABLE mst
DROP CONSTRAINT FK_mst

Friday, April 10, 2015

JavaScript isNaN() Function

Check whether a number is an illegal number:

var a = isNaN(123) + "<br>";
var b = isNaN(-1.23) + "<br>";
var c = isNaN(5-2) + "<br>";
var d = isNaN(0) + "<br>";
var e = isNaN("Hello") + "<br>";
var f = isNaN("2005/12/12") + "<br>";

var res = a + b + c + d + e + f;

false
false
false
false
true
true

Thursday, April 9, 2015

jQuery .change() event on asp.net dropdownlist isn't firing correctly

   $('#<%= Update_StatusDropDownList.ClientID %>').change(function() {
                alert($(this).val());
            });

Jquery check textbox entered value is decimal with single dot for multiple textboxes

 <script type="text/javascript">

        $('input[id$=Text1],input[id$=Text2],input[id$=Text3]').keypress(function (event) {

            return isNumber(event, this)

        });


        // THE SCRIPT THAT CHECKS IF THE KEY PRESSED IS A NUMERIC OR DECIMAL VALUE.
        function isNumber(evt, element) {

            var charCode = (evt.which) ? evt.which : event.keyCode

            if (
                (charCode != 45 || $(element).val().indexOf('-') != -1) &&      // “-” CHECK MINUS, AND ONLY ONE.
                (charCode != 46 || $(element).val().indexOf('.') != -1) &&      // “.” CHECK DOT, AND ONLY ONE.
                (charCode < 48 || charCode > 57))
                return false;

            return true;
        }
    </script>