JSFiddle - React, Tailwind, and code Playground
HTML
<input id='test' type="text" placeholder="0.0" />
<button>click</button>
<span></span>
JavaScript
function test(){
var result = true;
$("input").each(function() {
if (!this.value) {
this.value = 0;
}
if(jQuery.isNumeric(this.value) && this.value>=0){
}else{
result = false;
}
});
return result;
}
$('button').click(function(){
var finalValue = $('#test').val();
var testInput = test();
if(testInput){
$('span').text(finalValue);
}
});