JSFiddle - React, Tailwind, and code Playground
HTML
<input id="s20" type="text" name="text20" value="0" maxlength="5" />
JavaScript
if(!String.prototype.trim){
String.prototype.trim = function(){
return this.replace(/^\s+|\s+$/g,'');
};
}
document.getElementById('s20').onblur = function(){
var val = this.value;
if(!val.trim()) {
this.value = '0'
}
};