Monday, March 30, 2009

Numbers only in javascript

function checkIsNaN(e){
var unicode=e.charCode? e.charCode : e.keyCode
if (unicode!=8){
if (unicode<48||unicode>57)
return false //disable key press
}
}

call this method in
onkeypress="return checkIsNaN(event)"

2 comments:

deepu said...

Thank you for posting this.It helped me learn something new today

Jijo Mathew said...

thanx for you comment