Input predefined as Zero

by Krzysztof Niecikowski

HTML

<input type='text' class='pack' name='pack01' id='pack01' value='0'/><br>
<input type='text' class='pack' name='pack02' id='pack02' value='0'/>

JavaScript

$("input[name^=pack]").on("blur", function () {
    if (!this.value) {
        this.value = "0";
    }
});

$("input[name^=pack]").on("focus", function () {
    if (this.value = "0") {
        this.value = "";
    }   
});