Sony Ericsson Xperia X10 Preview
The folks at Cellulare-Magazine.it takes a look at the Sony Ericsson X10, the first Android smartphone by Sony Ericsson with the scape technology and intelligent face recognition. more
The folks at Cellulare-Magazine.it takes a look at the Sony Ericsson X10, the first Android smartphone by Sony Ericsson with the scape technology and intelligent face recognition. more
In this second part of a four-part series, I finish building a sample MySQL driver by adding to it a whole new class responsible for iterating over database result sets through a friendly and intuitive API. This functional example shows that the use of a simple static property makes it easier to implement the Singleton pattern, which is convenient when developing a class that abstracts the access to a database server, be it MySQL or a different one. >> More
function blockNonNumbers(obj, e, allowDecimal, allowNegative)
{
var key;
var isCtrl = false;
var keychar;
var reg;
if(window.event) {
key = e.keyCode;
isCtrl = window.event.ctrlKey
}
else if(e.which) {
key = e.which;
isCtrl = e.ctrlKey;
}
if (isNaN(key)) return true;
keychar = String.fromCharCode(key);
// check for backspace or delete, or if Ctrl was pressed
if (key == 8 || isCtrl)
{
return true;
}
reg = /\d/;
var isFirstN = allowNegative ? keychar == '-' && obj.value.indexOf('-') == -1 : false;
var isFirstD = allowDecimal ? keychar == '.' && obj.value.indexOf('.') == -1 : false;
return isFirstN || isFirstD || reg.test(keychar);
}
Use the below function in your HTML page
onkeypress="return blockNonNumbers(this, event, true, true);"