Level 9
Resolved. I changed #weighted_score to #total_weighted_score
Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.
I have this Laravel-5.8 code
<div class="col-12 col-sm-6">
<div class="form-group">
<label class="control-label"> Weight(%):<span style="color:red;">*</span></label>
<input type="number" name="weighted_score" id="total_weighted_score" placeholder="Enter weighted score here" class="form-control" max="120" onkeyup="checkScore(this.value)">
</div>
</div>
javascript
<script type="text/javascript">
function checkScore(value){
let max_score = $("#max_score").val();
let total_weighted_score = $("#total_weighted_score").val();
let sumValue = parseInt(total_weighted_score) + parseInt(value);
if (sumValue > max_score) {
alert("sum value is greater than max score");
$("#weighted_score").val('');
return false;
}
}
</script>
How do I clear the textbox when this condition:
if (sumValue > max_score) {
alert("sum value is greater than max score");
$("#weighted_score").val('');
return false;
}
is fulfilled.
Resolved. I changed #weighted_score to #total_weighted_score
Please or to participate in this conversation.