this is what I have so far:
$j(element)..keypress(function(e){
var val = $j(this).val();
if (("1234567890.").indexOf(e.charCode) > -1){
if (val.length > 0){
var regex = /(\+|-)?(\d*\.\d*)/;
if (regex.test(val)){
return true;
} else {
return false;
}
} else {
return true;
}
} else {
return false;
}
});
but for some reason, the text field only allows one character… and not even a number
With the help of @elclanrs and @mgibsonbr, I came to this:
which can be tested here: http://jsfiddle.net/9U2Mw/5/