Monday, April 13, 2015
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
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>
$('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>
Wednesday, April 8, 2015
sql newid()
Yes, newid() is unique. newid() returns a globally unique identifier. newid() will be unique for each call of newid().
Thus, newid() can be used as the value of a primary key of a sql server table. Values returned by newid() can be inserted into a primary key column of type "uniqueidentifier". Here is an example of a "uniqueidentifier" primary key column, with newid() used as the default value:
CREATE TABLE [tblUsers] (
[UserId] [uniqueidentifier] NOT NULL DEFAULT (newid()),
[UserName] [varchar](256) NOT NULL,
PRIMARY KEY ([UserId])
)
[UserId] [uniqueidentifier] NOT NULL DEFAULT (newid()),
[UserName] [varchar](256) NOT NULL,
PRIMARY KEY ([UserId])
)
Subscribe to:
Posts (Atom)