A Lot of javascript functions to assist you
<script language="JavaScript"
type="text/javascript">
function isNumber(n) {
return !isNaN(parseFloat(n)) &&
isFinite(n);
}
OR
Html
<input type="text"
id="numbersOnly"
/>
Javascript
<script language="JavaScript"
type="text/javascript">
var input =
document.getElementById('numbersOnly');
input.onkeydown = function(e) {
var k = e.which;
/* numeric inputs can come from
the keypad or the numeric row at the top */
if ( (k < 48 || k > 57) && (k
< 96 || k > 105)) {
e.preventDefault();
return false;
}
}
</script>
OR
Html
<input type="text" onKeyUp="numericFilter(this);" />
<script language="JavaScript" type="text/javascript">
Javascript
function numericFilter(txb){
txb.value =txb.value.replace(/[^\0-9]/ig, "");
}
</script>
No comments:
Post a Comment