<!DOCTYPE html> <html> <body> <input type="text" onkeyup = "this.value=parseInt(this.value) || 0"> </body> </html>